For example, the non-differentiable point of the function $f(x)=|x|$ is at $x=0$.
How to find the non-differentiable points of a continuous function that is defined numerically?
Answer
If we define f[x]
e.g. like this:
f[x_] := Abs[x]
the following returns interesting points:
Reduce[
Limit[(f[x + h] - f[x])/h, h -> 0, Assumptions -> x ∈ Reals, Direction -> -1] !=
Limit[(f[x + h] - f[x])/h, h -> 0, Assumptions -> x ∈ Reals, Direction -> 1], x]
x == 0
Let's try another function defined with Piecewise
, e.g.
g[x_] := Piecewise[{{x^2, x < 0}, {0, x == 0}, {x, 1 > x > 0},
{1, 2 >= x >= 1}, {Cos[x - 2] + x - 2, x > 2}}]
then we needn't use Assumptions
in Limit
:
Reduce[ Limit[ (g[x + h] - g[x])/h, h -> 0, Direction -> -1] !=
Limit[ (g[x + h] - g[x])/h, h -> 0, Direction -> 1], x]
x == 0 || x == 1 || x == 2
pts = {x, g[x]} /. {ToRules[%]};
Plot[ g[x], {x, -5/4, 3}, PlotStyle -> Thick,
Epilog -> {Red, PointSize[0.023], Point[pts]}]
One should be careful when working with Piecewise
since Reduce
may produce errors when weak inequalities (LessEqual
) are involved. For this reason we added {0, x == 0}
in the definition of the function g
.
Comments
Post a Comment