It seems like SymPy is having some issues plotting a Bessel function. This is the working example:
import sympy as sp
x = sp.symbols('x')
sp.plot(sp.besselj(4,x), (x,1,2))
When I try running the block above, I get the following stack trace:
File "/Users/..../test_bessel.py", line 5, in <module>
sp.plot(sp.besselj(4,x), (x,1,2))
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sympy/plotting/plot.py", line 419, in plot
plots.show()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sympy/plotting/backends/textbackend/text.py", line 21, in show
textplot(ser.expr, ser.start, ser.end)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sympy/plotting/textplot.py", line 167, in textplot
for line in textplot_str(expr, a, b, W, H):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sympy/plotting/textplot.py", line 67, in textplot_str
y.append(f(val))
^^^^^^
File "<lambdifygenerated-1>", line 2, in _lambdifygenerated
NameError: name 'besselj' is not defined
I don’t quite understand how besselj
is not defined, as I imported it with the sympy namespace. Any pointers here are greatly appreciated!
4