3

I am trying to run the following code:

f[t_] := {Cos[t], Sin[t], Cos[t]}
s = 0.1;
s1 = 2;

t[u_] := Normalize[f'[u]] n[u_] := Normalize[t'[u]] b[u_] := t[u][Cross]n[u]

Graphics3D[ { BSplineCurve[Table[f[u], {u, 0, 2 Pi, s}]], Arrow[Table[{f[u], t[u]}, {u, 0, 2 Pi, s1}]], Arrow[Table[{f[u], n[u]}, {u, 0, 2 Pi, s1}]] } ]

It works fine until I ask it to compute Arrow[Table[{f[u], t[u]}, {u, 0, 2 Pi, s1}]]. Trying to understand what the error was, I tried to compute n[1]//N and I noticed I obtain this:

enter image description here

Ie: It seems Mathematica differentiates Abs[x] but doesn't know what to so with it later. I tried to compute Abs'[1] and it didn't work. Is there something I can do for this to work? Perhaps some assumption I could use where it replaces Abs'[x] for something Mathematica knows how to handle?

Michael E2
  • 235,386
  • 17
  • 334
  • 747
Red Banana
  • 5,329
  • 2
  • 29
  • 47
  • 1
    Try:t[u_] := Simplify[Normalize[f'[u]], Assumptions -> u \[Element] Reals]. – Mariusz Iwaniuk Apr 17 '22 at 11:25
  • 1
    Possible duplicates: https://mathematica.stackexchange.com/questions/8188/simplifying-the-derivative-of-x, https://mathematica.stackexchange.com/questions/229650/cannot-derive-norm-or-normalize-when-recreating-frenet-serret-equations – Michael E2 Apr 17 '22 at 13:22
  • 1
    The trouble is that Abs is not complex differentiable, so you must insist to Mathematica that your domain is the reals. – John Doty Apr 17 '22 at 13:27

1 Answers1

8

Since Derivative[1][RealAbs][x] work, so we can use /. Abs -> RealAbs

Graphics3D[{BSplineCurve[Table[f[u], {u, 0, 2 Pi, s}]], 
   Arrow[Table[{f[u], t[u]}, {u, 0, 2 Pi, s1}]], 
   Arrow[Table[{f[u], n[u]}, {u, 0, 2 Pi, s1}]]}] /. Abs -> RealAbs

enter image description here

cvgmt
  • 72,231
  • 4
  • 75
  • 133