Code
In[830]:= curvature[x_, y_, z_, t_] :=
With[{s = {x, y, z}},
With[{v = D[s, t]},
With[{ fT = v / Norm[v]},
With[{fK = D[fT, t] / Norm[v]},
Norm[fK]
]
]
]
]
curvature[ Cos[t], Sin[t], t, t] /. t -> 1 // N
Out[831]= \[Sqrt](0.5 Abs[-0.59501 -
0.0955129 (-0.909297 Derivative[1][Abs][0.540302] +
0.909297 Derivative[1][Abs][0.841471])]^2 +
0.5 Abs[-0.382051 +
0.148752 (-0.909297 Derivative[1][Abs][0.540302] +
0.909297 Derivative[1][Abs][0.841471])]^2 +
0.015625 Abs[-0.909297 Derivative[1][Abs][0.540302] +
0.909297 Derivative[1][Abs][0.841471]]^2)
Question
I have a // N there.
Why do I not get a numerical answer. Instead, why do I have Derivative[1][Abs] all over the place?
Thanks!
EDIT
The following "fixes" the code. Why?
myNorm[lst_] := Sqrt[lst . lst]
curvature[x_, y_, z_, t_] :=
With[{s = {x, y, z}},
With[{v = D[s, t]},
With[{ fT = v / myNorm[v]},
With[{fK = D[fT, t] / myNorm[v]},
myNorm[fK]
]
]
]
]
curvature[ Cos[t], Sin[t], t, t] /. t -> 1 // N
This returns 0.5
Answer
According to the chain rule of differentiation, $(f\circ g)'(t)=f'(g(t))g'(t)$. Look at:
D[Abs[Sin[t]], t]
(* Cos[t] Derivative[1][Abs][Sin[t]] *)
You have several Abs[Sin[t]]
cropping up everywhere due to Norm[v]
in your code.
I would suggest re-writing the function as:
Clear[curvature2]
curvature2[vec : {x_, y_, z_}, t_] :=
With[{norm = Simplify[Norm@#, t ∈ Reals] &},norm[D[#/norm@#, t]/norm@#] &@D[vec, t]]
curvature2[{Cos[t], Sin[t], t}, t]
(* 1/2 *)
Comments
Post a Comment