2
$\begingroup$

I am new to Mathematica and I want to visualize the tangent and normal vector field of a particular embedding of the circle. In my code it is [CapitalGamma][s]. When I put the unit tangent vector (uT[s]) in Arrow[{}] I can manipulate a point with the corresponding unit tangent vector along my embedding but when I replace it with the unit normal (uN[s]) as I have defined it I get the following error:

Coordinate {0.4387912809451864 + (Abs[-0.8775825618903728 - 0.42073549240394825 Derivative[1][Norm][{-0.2397127693021015, 0.4387912809451864}]]^2 + Abs[-0.479425538604203 + 0.42073549240394825 Derivative[1][Norm][{-0.2397127693021015, 0.4387912809451864}]]^2)^Rat should be a pair of numbers, or a Scaled or Offset form.

Why is this happening? Any help would be greatly appreciated.

a = \[Pi]
c = \[Pi]/16
\[Rho] = 1/2
r[s_] := Piecewise[{{Sqrt[\[Rho]^2 - (s + a - \[Rho] - c)^2], 
    s <= -a + \[Rho] + c}, {\[Rho], -a + \[Rho] + c <= s <= 
     a - \[Rho] - c}, {Sqrt[\[Rho]^2 - (s - a + \[Rho] + c)^2], 
    s >= a - \[Rho] - c}}]

p[s_] := {Cos[s], Sin[s]}
n[s_] := {-Cos[s], -Sin[s]}

\[CapitalGamma][s_] := 
 Piecewise[{{p[s] + r[s]*n[s], 
    s <= a - c}, {p[2*a - 2*c - s] - 
     r[2*a - 2*c - s]*n[2*a - 2*c - s], s >= a - c}}]

uT[s_] := \[CapitalGamma]'[s]/Norm[\[CapitalGamma]'[s]]
uN[s_] := T'[s]/Norm[T'[s]]

Manipulate[
 Show[ParametricPlot[\[CapitalGamma][s], {s, -a + c, 3*a - 3*c}, 
   MaxRecursion -> 10, PlotPoints -> 60, Exclusions -> None], 
  AspectRatio -> Automatic, 
  Epilog -> {Red, AbsolutePointSize[6], Point[\[CapitalGamma][s]], 
    Arrow[{\[CapitalGamma][s], \[CapitalGamma][s] + 
       uT[s]}]}], {{s, .5}, -a + c, 3*a - 3*c, .01, 
  Appearance -> "Labeled"}]
```
$\endgroup$
2
  • 3
    $\begingroup$ Mathematica v12.2 evaluates your code without problems. Perhaps restart your kernel and rerun your code $\endgroup$ Aug 3, 2023 at 16:55
  • $\begingroup$ T[s] is not defined. $\endgroup$ Aug 3, 2023 at 20:05

1 Answer 1

2
$\begingroup$

Since Norm contain Abs and Abs is a function of a complex variable and is therefore not differentiable, we can replace Norm[v] to Sqrt[v.v].

That is we set ( we also set PerformanceGoal -> "Quality" and remove MaxRecursion -> 10).

Clear["Global`*"];
uT[s_] := Γ'[s]/Sqrt[Γ'[s] . Γ'[s]]

uN[s_] := uT'[s]/Sqrt[uT'[s] . uT'[s]]
a = π;
c = π/16;
ρ = 1/2;
r[s_] := 
 Piecewise[{{Sqrt[ρ^2 - (s + a - ρ - c)^2], 
    s <= -a + ρ + c}, {ρ, -a + ρ + c <= s <= 
     a - ρ - c}, {Sqrt[ρ^2 - (s - a + ρ + c)^2], 
    s >= a - ρ - c}}]
p[s_] := {Cos[s], Sin[s]}
n[s_] := {-Cos[s], -Sin[s]}
Γ[s_] := 
 Piecewise[{{p[s] + r[s]*n[s], 
    s <= a - c}, {p[2*a - 2*c - s] - 
     r[2*a - 2*c - s]*n[2*a - 2*c - s], s >= a - c}}]
uT[s_] := Γ'[s]/
  Sqrt[Γ'[s] . Γ'[s]]
uN[s_] := uT'[s]/Sqrt[uT'[s] . uT'[s]]
Manipulate[
 Show[ParametricPlot[Γ[s], {s, -a + c, 3*a - 3*c}, 
   PlotPoints -> 60, Exclusions -> None, 
   PerformanceGoal -> "Quality"], AspectRatio -> Automatic, 
  Epilog -> {Red, AbsolutePointSize[6], Point[Γ[s]], 
    Arrow[{Γ[s], Γ[s] + 
       uN[s]}]}], {{s, .5}, -a + c, 3*a - 3*c, .01, 
  Appearance -> "Labeled"}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.