Scroll to Top

Virtual Math Learning Center

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

Parametric Plots and Tangents at a Given t-value in Python

Author: David Manuel

In this video, the presenter shows how to plot a parametric curve in Python. The presenter then shows how to find the tangent line and plot it with the original parametric curve.

Transcript 16

Problem: Plot the parametrized curve \(x=t^3-3t^2,\) \(y=t^3-3t\) on \(t=[-2,3]\) and the tangent line at \(t=-2.\)

Python Code:
from sympy import *

x,t=symbols('x t')
xt=t**3-3*t**2
yt=t**3-3*t

matplotlib notebook

 pcurve=plot_parametric(xt,yt,(t,-2,3))

dydx=diff(yt,t)/diff(xt,t)
m=dydx.subs(t,-2)
x0=xt.subs(t,-2)
y0=yt.subs(t,-2)
tanline=y0+m*(x-x0)
print('The equation of the tangent line is y=',tanline)

pcurve.extend(plot(tanline,(x,-20,0)))
pcurve.show()

Open Python Notebook File

See more videos from this section