Michael E2 solves the problem of differentiability of multivariate functions.
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]
];
But when I applied it to the following univariate function problem, I encountered a problem:
$$\begin{array}{c} (A)\; f(x)=|x| \sin |x| \qquad (B)\; f(x)=|x| \sin \sqrt{|x|} \\ (C)\; f(x)=\cos |x| \qquad (D)\; f(x)=\cos \sqrt{|x|} \end{array}$$
differentiableQ[RealAbs[x] Sin[RealAbs[x]], {x} -> {0}]
differentiableQ[RealAbs[x] Sin[Sqrt[RealAbs[x]]], {x} -> {0}]
differentiableQ[Cos[RealAbs[x]], {x} -> {0}]
differentiableQ[Cos[Sqrt[RealAbs[x]]], {x} -> {0}]
The three functions A, B and C are differentiable at the point x=0, so the judgment result of the function differentiableQ is wrong.
How can I write a general user-defined function that can judge whether piecewise function, univariate function and multivariable function are differentiable at a certain point?
Mathematical analysis process:
$A: \quad f_{+}^{\prime}(0)=\lim _{x \rightarrow 0^{+}} \frac{|x| \sin |x|}{x}=0, f_{-}^{\prime}(0)=\lim _{x \rightarrow 0^{-}} \frac{-x \sin (-x)}{x}=0, \text { So } f^{\prime}(0)=0$
$B: \quad f_{+}^{\prime}(0)=\lim _{x \rightarrow 0^{+}} \frac{x \sin (\sqrt{x})}{x}=0, f_{-}^{\prime}(0)=\lim _{x \rightarrow 0^{-}} \frac{-x \sin (\sqrt{-x})}{x}=0, \Rightarrow f^{\prime}(0)=0$
$C: f_{+}^{\prime}(0)=\lim _{x \rightarrow 0^{+}} \frac{\cos x-1}{x}=\lim _{x \rightarrow 0^{+}} \frac{-\frac{1}{2} x^{2}}{x}=0, f_{-}^{\prime}(0)=\lim _{x \rightarrow 0^{-}} \frac{\cos (-x)-1}{x}=0, \Rightarrow f^{\prime}(0)=0$
$D: \begin{aligned} f_{+}^{\prime}(0)=\lim _{x \rightarrow 0^{+}} \frac{\cos \sqrt{x}-1}{x}=\lim _{x \rightarrow 0^{+}} \frac{-\frac{1}{2} x}{x}=-\frac{1}{2}\\ f_{-}^{\prime}(0)=\lim _{x \rightarrow 0^{-}} \frac{\cos (\sqrt{-x})-1}{x}=\lim _{x \rightarrow 0^{-}} \frac{-\frac{1}{2}(-x)}{x}=\frac{1}{2} \end{aligned}$

Limit[D[f[x],x],x->0]already shows whether the function is differentiable - the issue with the "more robust" solution is that inserting0into the Jacobian does not work without taking the limit. But since the whole point of this function is to work around the shortcomings onLimit, I'm not sure how to best fix this – Lukas Lang Aug 03 '20 at 08:31Limit[D[f[x],x],x->0]will show whether the derivative is continuous. It fails to showPiecewise[{{x^2 Sin[1/x], x != 0}}]is differentiable atx = 0. – Michael E2 Aug 03 '20 at 12:27differentiableQassumesD[]can compute the Jacobian strictly correctly, which it fails to do in these cases. Theoretically, you could replaceD[]injac = D[f, {v}]by the limits for each partial derivative. Of course,Limitis not completely reliable, either. – Michael E2 Aug 03 '20 at 19:14Indeterminatefor only the last example), I didn't think twice about the actual meaning of that limit – Lukas Lang Aug 03 '20 at 20:44