Simplifying Difference Quotients in Python

Author: David Manuel
In this video, it is demonstrated how to simplify difference quotients in Python. It is then shown how to use Python to find the derivative of the function by substituting \(h=0\) in the simplified difference quotient.

Transcript 11

Exercises

from sympy import *

# Use limit definition to find derivative of f(x)=1/x^3
h,x=symbols('h x')
f=1/x**3
#Step 1 command: subs
diffqt=(f.subs(x,x+h)-f)/h
print('The difference quotient is',diffqt)
#Step 2 command: factor, expand, or simplify
print(diffqt.expand().simplify())
#Step 3 command: subs
print(diffqt.expand().simplify().subs(h,0))