I want to plot the second derivative of the Hankel function using Simpy. In Mathematica it is as easy as:
D[HankelH2[1,z],z]
This can be done analytically by using the property,
But I want to learn how to derivate it directly using Sympy. So far I've tried this:
from scipy.special import hankel2
import sympy as sp
x = sp.Symbol('x')
dh2 = sp.diff(lambda x: hankel2(1,x),x)
The error message seems illegible to me:
SympifyError Traceback (most recent call last) in () 1 import sympy as sp 2 x = sp.Symbol('x') ----> 3 dh2 = sp.diff(lambda x: hankel2(1,x),x)
/usr/lib/python2.7/dist-packages/sympy/core/function.pyc in diff(f, *symbols, **kwargs) 1639 """ 1640 kwargs.setdefault('evaluate', True) -> 1641 return Derivative(f, *symbols, **kwargs) 1642 1643
/usr/lib/python2.7/dist-packages/sympy/core/function.pyc in new(cls, expr, *variables, **assumptions) 985 def new(cls, expr, *variables, **assumptions): 986 --> 987 expr = sympify(expr) 988 989 # There are no variables, we differentiate wrt all of the free symbols
/usr/lib/python2.7/dist-packages/sympy/core/sympify.pyc in sympify(a, locals, convert_xor, strict, rational, evaluate) 313 expr = parse_expr(a, local_dict=locals, transformations=transformations, evaluate=evaluate) 314 except (TokenError, SyntaxError) as exc: --> 315 raise SympifyError('could not parse %r' % a, exc) 316 317 return expr
SympifyError: Sympify of expression 'could not parse u' at 0x7fdf3eca9e60>'' failed, because of exception being raised: SyntaxError: invalid syntax (, line 1)
Any clue where is my mistake?
Thanks in advance.