0
$\begingroup$

Let my function be $f(x)=e^{|x|}$. I wish to find $f''(x)$, this can be done as-

$f'(x)=$sgn$(x)e^{|x|}$

$f''(x)=$sgn$(x)^2e^{|x|} =e^{|x|}$

In Mathematica, I am trying to plot $f''(x)$, it presents an empty plot.

f[x_] := E^Abs[x];
Plot[f[x], {x, -1, 1}]

enter image description here

g[x_] = D[f[x], {x, 2}]
Plot[g[x], {x, -1, 1}]

enter image description here

Could anyone please locate the error.

$\endgroup$

2 Answers 2

3
$\begingroup$

You could use RealAbs instead of Abs:

FullSimplify[
    D[Exp[RealAbs[x]],x,x],
    x ∈ Reals
]

E^RealAbs[x]

Another possibility is to use ComplexExpand:

Simplify[
    D[ComplexExpand[Exp[Abs[x]]],x,x],
    x ∈ Reals
]

E^Abs[x]

$\endgroup$
9
  • $\begingroup$ RealAbs[] is not working in my computer :( $\endgroup$
    – quanta
    Oct 10, 2018 at 5:50
  • $\begingroup$ Alas! Again is not working :( $\endgroup$
    – quanta
    Oct 10, 2018 at 5:53
  • $\begingroup$ @SachinKumar What version of Mathematica? $\endgroup$
    – Carl Woll
    Oct 10, 2018 at 5:54
  • $\begingroup$ It is version 9.0 $\endgroup$
    – quanta
    Oct 10, 2018 at 5:58
  • 1
    $\begingroup$ @Sachin, Exp[Piecewise[{{x, x > 0}, {-x, x < 0}}, 0]] should also work in version 9 for your purposes. $\endgroup$ Oct 10, 2018 at 10:53
0
$\begingroup$

An easy workaround for real x is to use Sqrt[x^2] instead of Abs[x]

Plot[D[Exp[Sqrt[x^2]], x] // Evaluate, {x, -1, 1}]
$\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.