I'm trying to use this function in mathematica 11:
differentiableAtQ[
f_, p_?VectorQ, vars_?VectorQ, dom_ : Reals
] := With[{n = Length[vars], dimP = Length[p]},
If[n < 1 || n != dimP, Return[]];
If[n > 1,
With[{pd = D[f, #] & /@ vars},
With[{pdValues = ((Evaluate[vars] \[Function] #) @@ p) & /@ pd},
(* All partial derivatives exist *)
AllTrue[pdValues, NumericQ] &&
With[{$f = Evaluate[vars] \[Function] Evaluate[f]},
(* All partial derivatives are continuous *)
AllTrue[{pd, pdValues}\[Transpose],
Apply[Limit[#1, vars -> p] === #2 &]
] || Switch[ (* Taking limit *)
Limit[FullSimplify[
(If[MemberQ[#, _Piecewise, \[Infinity]],
# // PiecewiseExpand, #] &)[
(* Edit for correction (n-1) *)
($f @@ vars + (n - 1) $f @@ p
- Total[
$f @@@ (ConstantArray[vars, n]
+ DiagonalMatrix[p - vars])
])/Norm[vars - p]],
And @@ Thread[vars != p]
&& vars \[Element] dom],
vars -> p],
0, True,
Indeterminate, False,
_DirectedInfinity, False,
_, Indeterminate
]
]]],
D[f, vars] /. vars[[1]] -> p[[1]] // NumericQ
]]
copied from this question How to write a custom function to judge whether a bivariate function is differentiable at a certain point?
Maybe in mathematica 12 it works fine, but in 11 if I test it with some examples taken from the same post, it say:
General : {x,y} is not a valid variable .
So, how can I adapt this function to make it usable in mathematica 11?
Limit
only gained the functionality for multi-dimensional limits in version 11.2, so in version 11 you can only consider the limit along parametrized paths. I am not sure how exactly to replace this functionality, since multi-dimensional limits are not easy to compute, as existence of the limit along a path does not prove the multi-variate limit exists (check e.g. this question) $\endgroup$f[x+x0, y+y0] /. {x -> r Cos[θ], y -> r Sin[θ]}
and then take the limit asr->0
. If the result is dependent on θ or not a constant function then the limit is indeterminate, otherwise it should work. The same should work for a shrinking sphere in 3D. ^ Note: this assumes the f is continuous on the disks everywhere except the point x0,y0 $\endgroup$