xvals = linspace(a, b, 1001)
expr = //string taken as input
yvals=list()
for x in xvals:
y=eval(expr)
yvals.append(y)
plt.plot(xvals, yvals)
This works fine for any polynomial function But gives error in case of sin(x) or log(x) : name 'sin(x)' is not defined How to resolve this?