# Problem in dealing with Sign function

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}]


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


Could anyone please locate the error.

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]

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

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}]