var('x,y,z,t,r')
r=vector([sin(t),cos(t),2*t])
print"Problem 1: "
print"1. + 2. = graph"
def tangentVector(r,t):
return(diff(r,t)/norm(diff(r,t)))
def normalVector(r,t):
return(diff(tangentVector(r,t),t)/(norm(diff(tangentVector(r,t),t))))
def binormalVector(r,t):
return(tangentVector(r,t).cross_product(normalVector(r,t)))
def Plottangent(r,t,to,**kwarg):
var('u,to')
r0=r(t=to)
Ta=tangentVector(r,t)(t=to)
return parametric_plot3d(list(r0+Ta*u),(u,0,1),**kwarg)
def Plotnormal(r,t,to,**kwarg):
var('u,to')
r0=r(t=to)
No=normalVector(r,t)(t=to)
return parametric_plot3d(list(r0+No*u),(u,0,1),**kwarg)
def Plotbinormal(r,t,to,**kwarg):
var('u,to')
r0=r(t=to)
Bi=binormalVector(r,t)(t=to)
return parametric_plot3d(list(r0+Bi*u),(u,0,1),**kwarg)
A = parametric_plot3d(r(t),(t,-10,10), thickness = 5)
B = Plottangent(r(t),t,-2,thickness=5,color='red')
C = Plotnormal(r(t),t,-2,thickness=5,color='green')
D = Plotbinormal(r(t),t,-2,thickness=5,color='orange')
E = implicit_plot3d(x==-19.99,(x,-20,20),(y,-20,20),(z,-20,20),color='white')
F = numerical_approx(integral(norm(diff(r,t)),t,0,-2))
print"3. length of the curve from t=0 to t=-2: ",F
r1 = diff(r,t)
r2 = diff(r1,t)
curvature = (norm(r1.cross_product(r2))/((norm(r1))^3))
print"4. curvature at t=-2: ",numerical_approx(curvature(t=2))
A+B+C+D+E