Function Repository Resource:

PossiblyDifferentiableQ

Source Notebook

Determine whether a single-variable, real-valued function is differentiable

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["PossiblyDifferentiableQ"][f,x]

returns True if f is differentiable with respect to x for all real numbers.

ResourceFunction["PossiblyDifferentiableQ"][f,{x,n}]

returns True if f is n-times differentiable with respect to x for all real numbers.

ResourceFunction["PossiblyDifferentiableQ"][{f,cons},x]

returns True if f is differentiable with respect to x for the real numbers that satisfy the constraint cons.

ResourceFunction["PossiblyDifferentiableQ"][{f,cons},{x,n}]

returns True if f is n-times differentiable with respect to x for the real numbers that satisfy the constraint cons.

Details

ResourceFunction["PossiblyDifferentiableQ"] has the attribute HoldFirst.
ResourceFunction["PossiblyDifferentiableQ"] takes only real-valued functions.
The constraint cons can be any logical combination of equations or inequalities:
lhs==rhsequations
lhs>rhs,lhsrhs,lhs<rhs,lhsrhsinequalities (LessEqual,)

Examples

Basic Examples (1) 

Determine if a function is differentiable over all real numbers:

In[1]:=
ResourceFunction["PossiblyDifferentiableQ"][x^2, x]
Out[1]=
In[2]:=
ResourceFunction["PossiblyDifferentiableQ"][1/x, x]
Out[2]=

Scope (3) 

Determine if a function is differentiable for a particular set of x-values:

In[3]:=
ResourceFunction["PossiblyDifferentiableQ"][{RealAbs[x], x > 4}, x]
Out[3]=

The constraint can also be a logical combination of inequalities:

In[4]:=
ResourceFunction[
 "PossiblyDifferentiableQ"][{1/(x^2 - 4), x > -1 && x < 2}, x]
Out[4]=

Determine if a function is 5-times differentiable:

In[5]:=
ResourceFunction["PossiblyDifferentiableQ"][Cos[x], {x, 5}]
Out[5]=

Properties and Relations (1) 

PossiblyDifferentiableQ has the attribute HoldFirst, enabling calculations such as the following:

In[6]:=
ResourceFunction["PossiblyDifferentiableQ"][x/x, x]
Out[6]=

Possible Issues (2) 

For some edge cases, PossiblyDifferentiableQ will return True even if the given function is not differentiable everywhere:

In[7]:=
fnc[x_] := Piecewise[{{x Sin[1/x], x != 0}, {0, x == 0}}];
In[8]:=
ResourceFunction["PossiblyDifferentiableQ"][fnc[x], x]
Out[8]=

Since PossiblyDifferentiableQ takes only real-valued functions, it will treat Abs as RealAbs:

In[9]:=
ResourceFunction["PossiblyDifferentiableQ"][Abs[x], x]
Out[9]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 2.0.0 – 23 March 2023
  • 1.0.0 – 04 January 2022

Related Resources

Author Notes

To view the full source code for PossiblyDifferentiableQ, evaluate the following:

In[1]:=
SystemOpen[
 FileNameJoin[{DirectoryName[FindFile["ResourceFunctionHelpers`"]], "FunctionDifferentiability.wl"}]]

License Information