15

I'm doing this exercise in Wagner's book (p.78)

Mathematica graphics

, and this is my attempt:

Clear[curvature];

(*Define curvature function *)
curvature[x_, y_, z_] := Module[{s, v, T},
  s = {x, y, z};
  v = D[s, t];
  T = v/Norm[v];
  Simplify[Norm[D[T, t]/Norm[v]]]]

(* Apply function to Cos[t],Sin[t],t *)
curvature[Cos[t], Sin[t], t]

Mathematica graphics

As you could see I did not get the expected answer (1/2) when applying my curvature function.

It also would not reduce even when a value for t was substituted:

curvature[Cos[t], Sin[t], t] /. t -> 4

Mathematica graphics

However, following Wagner's solution where he defines a separate magnitude function does work:

Clear[curvature];

(* Define function to find magnitude of a vector *)
mag[vec_] := Sqrt[vec.vec]

(* Define curvature function *)
curvature[x_, y_, z_] := Module[{s, v, T},
  s = {x, y, z};
  v = D[s, t];
  T = v/mag[v];
  Simplify[mag[D[T, t]/mag[v]]]]

(* Apply function to Cos[t],Sin[t],t *)
curvature[Cos[t], Sin[t], t]

Mathematica graphics

It seems pretty clear that using Norm to find the magnitude of a vector does not work in this case. More specifically, using Norm doesn't seem to simplify trigonometric results unless the t is substituted

Norm[{Cos[t], Sin[t]}]
Norm[{Cos[t], Sin[t]}] /. t -> 4 // Simplify

Mathematica graphics

I'm very fuzzy on my matrix knowledge so I'd really appreciate an explanation on why Norm doesn't seem to return the expected answer in this case. Also, is there any other way to find a vector's magnitude that will give the correct answer without defining a new function?

seismatica
  • 5,101
  • 1
  • 22
  • 33

3 Answers3

15

Norm in general assumes complex arguments and uses Abs to provide for that:

Norm[{x, y}]

Sqrt[Abs[x]^2 + Abs[y]^2]

For real elements, you can either add an assumption for Simplify or manually get rid of Abs beforehand:

Simplify[Norm[{Cos[t], Sin[t]}], Element[t, Reals]]
Simplify[Norm[{Cos[t], Sin[t]}] /. Abs -> Identity]

1

1

This now returns the desired result for real t:

curvature[x_, y_, z_] := Module[{s, v, T}, s = {x, y, z};
  v = D[s, t];
  T = v/Norm[v];
  Simplify[Norm[D[T, t]/Norm[v]] /. Abs -> Identity]]

curvature[Cos[t], Sin[t], t]

1/2

Yves Klett
  • 15,383
  • 5
  • 57
  • 124
7

EDIT

With V10 we can use

ArcCurvature[2 {Cos[t], Sin[t]}, t]

1/2

Or

FrenetSerretSystem[a {Cos[t], Sin[t]}, t]

enter image description here

yielding curvature, tangent, and normal

Original answer

An alternative:

$Assumptions = t \[Element] Reals;

J[{x_, y_}] := {-y, x}

Curvature[a_][t_] := a''[t].J[a'[t]]/Norm[J[a'[t]]]^3 // Simplify

circle[a_][t_] := {a Cos[t], a Sin[t]}

Curvature[circle[2]][t]

enter image description here

ellipse[a_, b_][t_] := {a Cos[t], b Sin[t]}

Curvature[ellipse[2, 3]][t]

enter image description here

Curvature[ellipse[2, 3]][Pi]

enter image description here

$Assumptions = True; (* Clear *)
eldo
  • 67,911
  • 5
  • 60
  • 168
  • Thank you for your answer. Could you help me understand why you defined a function with 2 parameters in separate brackets? – seismatica Jul 03 '14 at 19:45
  • @seismatica I think it's just a matter of personal taste. Makes code clearer for me in the ellipse-case (t vs. Pi). – eldo Jul 03 '14 at 19:58
6

Here is a version of curvature that uses Mathematica machinery not available to Wagner, who used V3.

curvature[x_, y_, z_] :=
  Module[{s, v, vMag, T},
    Block[{$Assumptions = {{x, y, z} ∈ Reals}},
      s = {x, y, z};
      v = D[s, t];
      vMag = Surd[v.v, 2];
      T = v/vMag;
      Simplify[Norm[D[T, t]/vMag]]]]
curvature[Cos[t], Sin[t], t]
1/2
m_goldberg
  • 107,779
  • 16
  • 103
  • 257