Tangents to Parametrized Curves at a Given Point
In this example, we use Python to find and plot a line tangent to a parametrized curve at a specific point. We will plot the curve parametrized by x=cos^3(t), y=sin^3(t) at the point (1/27, 16sqrt(2)/27). As usual, we start by loading the symbolic package into Python, then define t as a symbolic variable using the symbols command before defining xt and yt as our expressions (since we will need the symbolic variable x for the tangent line equation). Now we follow our strategy, describing how to find the equation of the tangent line by hand:
1) Solve x=1/27, y=16sqrt(2)/27 to find t (solve). NOTE that if you want to see the exact value, you can use the Rational command on the fractions: x=Rational(1,27), y=Rational(16,27)*sqrt(2) (you can only put integers in the Rational command)
2) Find the derivative using the formula dy/dx = (dy/dt) / (dx/dt) (diff)
3) Substitute the t-value from #1 into the derivative to find the slope (subs). NOTICE that the t-value is inside a tuple (this is because there were two equations) which is inside a list, so we put two indexes: it is the 0th element of the tuple which is the 0th element in the list.
4) Define a variable for the tangent line equal to y0 + m*(x-x0)
5) Plot the parametrized curve (plot_parametric) and the tangent line (plot)
Since we are using different plot commands, to put them on the same graph, we assign a variable to the first plot such as pcurve, then use .extend at the end of the variable, including our tangent line plot at an option