This article is an example of how to find derivatives in Python. Shared for your reference. Specific implementation method is as follows:
def func(coeff): sum='' for key in coeff: sum=sum+'+'+str(key)+'*'+'x'+'**'+str(coeff[key]) return sum[1:] from sympy import * from import SympifyError expr = func({2:0,3:1,4:2,5:7}) x = Symbol("x") sexpr = sympify(expr) print diff(sexpr, x) print diff(sexpr, x).subs('x',3)
Use a dictionary to accomplish this:
(2+3*x+4*x**2+7*x**3.7).diff(x).subs({x:3}).evalf()
I hope that what I have described in this article will help you in your Python programming.