3
$\begingroup$

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?

$\endgroup$
3

1 Answer 1

8
$\begingroup$

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

$\endgroup$
2
  • 3
    $\begingroup$ +1 RealAbs was introduced in v11.1; for earlier versions for real x, use Abs[x] :> Sqrt[x^2] $\endgroup$
    – Bob Hanlon
    Apr 17 at 13:30
  • $\begingroup$ @BobHanlon Thank you! Forget the gym... that's a smart way to get real abs :) $\endgroup$ Apr 17 at 23:20

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