0
$\begingroup$

I need to calculate derivatives of absolute value as follows $$ \frac{d}{dr_1}\lvert r_1-r_2\rvert $$ somewhere in my calculations. When I simply use D[Abs[r1-r2],r1]it returns Abs'[r1-r2]! and I don't know how to deal with it. Doesn't Mathematica yield an explicit answer in this case?!

$\endgroup$
3
  • 1
    $\begingroup$ See the above, Try D[RealAbs[r1 - r2], r1] so instead of D[Abs[x],x] use D[RealAbs[x], x] $\endgroup$
    – Nasser
    Commented Sep 2, 2021 at 4:15
  • $\begingroup$ @Nasser Oh, Thanks bro! seems you hit the spot! $\endgroup$
    – Wisdom
    Commented Sep 2, 2021 at 4:22
  • 1
    $\begingroup$ Note that Abs'[r1 - r2] is Derivative[1][Abs][r1 - r2]; you can in fact give definitions like Derivative[1][Abs]=Sign if you like, as Derivative is not protected. $\endgroup$
    – thorimur
    Commented Sep 2, 2021 at 5:15

0

Browse other questions tagged or ask your own question.