# Curvature, T, N, & B

A classic topic in multivariable calculus involves the study of a vector valued function ${\bf r}(t)=\langle x(t),y(t),z(t) \rangle$ using the three canonical unit vectors —  the tangent vector ${\bf T}(t)$, the normal vector ${\bf N}(t)$, and the Binormal vector ${\bf B}(t)$ — and the scalar curvature $\kappa(t)$.

Here are maxima functions that compute these, called
unitT, unitN, unitB, and curvature.  For a vector valued function ${\bf r}(t)$, these are called as

T(t):=unitT(r(t),t);

/* unitT computes the unit tangent vector for a vector valued function
of a scalar variable r(t)=[x(t),y(t),z(t)] */

unitT(r,t):=
block([rp,rpn,T],
define(rp(t),diff(r,t)),
define(rpn(t),sqrt(rp(t).rp(t))),
define(T(t),rp(t)/rpn(t)),
trigsimp(T(t))
)$/* unitN computes the unit normal vector for a vector valued function of a scalar variable r(t)=[x(t),y(t),z(t)] unitN requires unitT */ unitN(r,t):= block([T,Tp,Tpn,N], define(T(t),unitT(r,t)), define(Tp(t),diff(T(t),t)), define(Tpn(t),sqrt(Tp(t).Tp(t))), define(N(t),Tp(t)/Tpn(t)), trigsimp(N(t)) )$

/* unitB computes the unit normal vector for a vector valued function
of a scalar variable r(t)=[x(t),y(t),z(t)]
unitB requires unitT and unitN */

unitB(r,t):=
block([T,N,B],
define(T(t),unitT(r,t)),
define(N(t),unitN(r,t)),
define(B(t),[T(t)*N(t)-T(t)*N(t),
T(t)*N(t)-T(t)*N(t),
T(t)*N(t)-T(t)*N(t)]),
trigsimp(B(t))
)$/* curvature computes the curvature curvature requires unitT */ curvature(r,t):= block([T,Tdot,rdot,K], define(T(t),unitT(r,t)), define(Tdot(t),diff(T(t),t)), define(rdot(t),diff(r,t)), define(K(t),trigsimp(sqrt(Tdot(t).Tdot(t)/rdot(t).rdot(t)))), K(t) )$