I'm experimenting with sympy and I've hit upon an issue I can't work out.
Using scipy I can write an expression and evaluate it for an array of x values as follows:
import scipy
xvals = scipy.arange(-100,100,0.1)
f = lambda x: x**2
f(xvals)
Using sympy I can write the same expression as follows:
import sympy
x = sympy.symbols('x')
g = x**2
I can evaluate this expression for a single value by doing the following:
g.evalf(subs={x:10})
However I can't work out how to evaluate it for an array of x values, like I did with scipy. How would I do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…