Scroll to Top

Virtual Math Learning Center

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

Finding Derivatives in Python

Author: David Manuel

In this video, it is demonstrated how to find derivatives in Python. The presenter solves an example the rate of change of force as a box is dragged along the ground by a rope attached to a pulley.

Transcript 08

Problem: Suppose a mass \(m\) is dragged across the ground by a rope attached to a pulley. Suppose that \(x\) is the horizontal distance from the mass to the pulley, \(h\) is the height of the pulley, and \(F\) is the force applied to the rope. Let \(g\) be the acceleration due to gravity, and \(\mu\) be the friction coefficient of the box along the ground. It can be shown that the force is given by this equation
\[F=\frac{\mu m g\sqrt{x^2+h^2}}{x+\mu h}\]
How fast is the force changing with respect to \(x\) in general? How fast is it changing when \(m=18,\) \(h=10,\) \(\mu=0.55\), \(g=9.8,\) \(x=10\) and \(x=40.\)

Python Code:
from sympy import *

mu,m,g,x,h=symbols('mu m g x h')
F=mu*m*g*sqrt(x**2+h**2)/(x+mu*h)
dF=F.diff(x)print('The general derivative is',dF)
dFat10=F.subs({m:18,h:10,mu:0.55,g:9.8,x:10})
print('When x=10, the rate of change in t is',dFat10.evalf() ,'Newtons/meter')

dFat40=F.subs({m:18,h:10,mu:0.55,g:9.8,x:40})
print('When x=40, the rate of change in t is', dFat40.evalf(), 'Newtons/meter')

Open Python Notebook File

See more videos from this section