#
#
`PROBLEM: find the equation of the tangent line to the lemniscate at t = Pi/4 and plot the curve and the tangent line`;
`The parametric equations for the lemniscate are given in R`;
R := [sqrt(sin(2*t))*cos(t), sqrt(sin(2*t))*sin(t)];
`Now we save the plot for the lemniscate into the variable curve`;
`curve := plot([sqrt(sin(2*t))*cos(t), sqrt(sin(2*t))*sin(t),t=0..2*Pi]):`;
curve := plot([sqrt(sin(2*t))*cos(t), sqrt(sin(2*t))*sin(t),t=0..2*Pi]):
`to get the position vector for the tangent line we need to evaluate R at t = Pi/4`;
P := subs(t=Pi/4,R);
P := map(simplify,P);
v := subs(t=Pi/4, diff(R,t));
v := map(simplify,v);
L := evalm(P + s*v);
line := plot([L[1],L[2],s=-2..2]):
#with(plots): display3d({curve,line});
#