I encountered a problem in solving the math problem in China's 2019 postgraduate entrance examination.
I need to judge whether $f(x)=\left\{\begin{array}{cc} x|x|, & x \leq 0 \\ x \ln x, & x>0 \end{array}\right. $ is differentiable at the point x = 0 and whether it is an extreme point.
The code in this post can be used to judge whether it is differentiable or not:
differentiableQ[f_, spec : (v_ -> v0_)] :=
With[{jac = D[f, {v}]},
Module[{f0, jac0}, {f0, jac0} = {f, jac} /. Thread[spec];
VectorQ[Flatten@{f0, jac0}, NumericQ] &&
Limit[(f - f0 - jac0.(v - v0))/Sqrt@Total[(v - v0)^2], spec] ===
0] /; VectorQ[jac]];
ClearAll[differentiableQ, dLimit];
differentiableQ[f_, spec : (v_ -> v0_)] :=
With[{jac = D[f, {v}]},
Module[{f0, jac0, res}, {f0, jac0} = {f, jac} /. Thread[spec];
If[VectorQ[Flatten@{f0, jac0}, NumericQ],
res = Limit[(f - f0 - jac0.(v - v0))/Sqrt@Total[(v - v0)^2],
spec] /.
HoldPattern[Limit[df_, s_]] /; ! FreeQ[df, Piecewise] :>
With[{L = dLimit[df, s]}, L /; FreeQ[L, dLimit]];
res =
FreeQ[res, Indeterminate] && And @@ Thread[Flatten@{res} == 0],
res = False]] /; VectorQ[jac]];
dLimit[df_, spec_] :=
Module[{f0, jac0, pcs = {}, z, res},
pcs = Replace[(*Solve[..,Reals] separates PW fn*)
z /. Solve[z == df, z,
Reals], {ConditionalExpression[y_, c_] :> {y, c},
y_ :> {y, True}}, 1];
If[ListQ[pcs],
res = (Limit[Piecewise[{#}], spec] /.
HoldPattern[Limit[Piecewise[{{y_, _}}, 0], s_]] :>
With[{L = Limit[y, s]}, L /; FreeQ[L, Limit]] & /@ pcs)];
res /; ListQ[pcs]];
f[x_] := Piecewise[{{xRealAbs[x], x <= 0}, {xLog[x], x > 0}}]
differentiableQ[f[x], {x} -> {0}]
Now I want to judge whether the point x = 0 is the extreme point of function $f(x)=\left\{\begin{array}{cc} x|x|, & x \leq 0 \\ x \ln x, & x>0 \end{array}\right. $ . However, MMA has no built-in function to determine whether a point is an extreme point. How to define a custom function to determine the extreme point?



