Scroll to Top

Virtual Math Learning Center

Virtual Math Learning Center Texas A&M University Virtual Math Learning Center

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

Problem: Use the limit definition to find the derivative of \[f(x)=\frac{1}{x^3}\]

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))

See more videos from this section