@@ -313,6 +313,13 @@ def map_Mul(self, expr): # noqa: N802
313313
314314 return math .prod (num_args ) / math .prod (den_args )
315315
316+ def map_FunctionSymbol (self , expr ):
317+ if expr .get_name () == "ExpI" :
318+ arg = self .rec (expr .args [0 ])
319+ return prim .Variable ("cos" )(arg ) + 1j * prim .Variable ("sin" )(arg )
320+ else :
321+ return SympyToPymbolicMapperBase .map_FunctionSymbol (self , expr )
322+
316323
317324class PymbolicToSympyMapperWithSymbols (PymbolicToSympyMapper ):
318325 def map_variable (self , expr ):
@@ -338,6 +345,9 @@ def map_call(self, expr):
338345 args = [self .rec (param ) for param in expr .parameters ]
339346 args .append (0 )
340347 return BesselJ (* args )
348+ elif expr .function .name == "expi" :
349+ args = [self .rec (param ) for param in expr .parameters ]
350+ return ExpI (* args )
341351 else :
342352 return PymbolicToSympyMapper .map_call (self , expr )
343353
@@ -369,8 +379,20 @@ class Hankel1(_BesselOrHankel):
369379 pass
370380
371381
382+ class ExpI (sympy .Function ):
383+ """A symbolic function that takes a real value as an
384+ input and returns a complex number such that
385+ expi(x) = exp(i*x).
386+ """
387+ nargs = (1 ,)
388+
389+ def fdiff (self , argindex = 1 ):
390+ return self .func (self .args [0 ]) * sympy .I
391+
392+
372393_SympyBesselJ = BesselJ
373394_SympyHankel1 = Hankel1
395+ _SympyExpI = ExpI
374396
375397if USE_SYMENGINE :
376398 def BesselJ (* args ): # noqa: N802 # pylint: disable=function-redefined
@@ -379,4 +401,7 @@ def BesselJ(*args): # noqa: N802 # pylint: disable=function-redefined
379401 def Hankel1 (* args ): # noqa: N802 # pylint: disable=function-redefined
380402 return sym .sympify (_SympyHankel1 (* args ))
381403
404+ def ExpI (* args ): # noqa: N802 # pylint: disable=function-redefined
405+ return sym .sympify (_SympyExpI (* args ))
406+
382407# vim: fdm=marker
0 commit comments