0

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.

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
Schrodinger
  • 942
  • 4
  • 14

2 Answers2

3

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]

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
0

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}]
Ulrich Neumann
  • 53,729
  • 2
  • 23
  • 55