Use sympy to find the value ($ = 6 $) of the derivative of $ x ^ 3 $ ($ = 3 x ^ 2 $) at $ x = a = 2 $.
The derivative is obtained by using the ** diff ** method, and the derivative value is obtained by evaluating the limit value of x-> a using the ** limit ** method.
derivative.py
from sympy import *
x=Symbol('x') #letter'x'Is defined as the variable x
"""
Example: x^3 x=Find the value of the derivative in 2
"""
def dfdx(x,a):
return limit(diff(x**3,x),x,a)
dfdx(x,2)
6