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 follow
Or you can do it via numpy.vectorize. I am using x, g, and xvals from the question body.
x
g
xvals
scalar_func = lambda xx: float(g.evalf(subs={x: xx})) vector_func = numpy.vectorize(scalar_func) vector_func(xvals) # returns a numpy array [10000.0, 9980.01, 9960.04, ...]