# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

The derivative of a piecewise function with Indeterminate for points or regions where the function is not defined

Contributed by:
Dennis M Schneider

ResourceFunction["PiecewiseD"][ returns the derivative of a piecewise function returning the value Indeterminate for points or regions where the function is not defined. | |

ResourceFunction["PiecewiseD"][ returns the function together with its first | |

ResourceFunction["PiecewiseD"][ returns the |

Compute the derivative of a piecewise function:

In[1]:= |

Out[2]= |

Compute the derivatives of a function whose domain is not an interval:

In[3]:= |

Out[4]= |

Compute just the third derivative:

In[5]:= |

Out[5]= |

Plot the function together with its first three derivatives:

In[6]:= |

Out[6]= |

Find and plot the first- and second-order derivatives. The function and its first-order derivative are continuous at *x*=0, but not the second-order derivative:

In[7]:= |

Out[8]= |

Check that the first derivative is continuous:

In[9]:= |

Out[9]= |

Check that the second derivative is not continuous:

In[10]:= |

Out[10]= |

Plot the results:

In[11]:= |

Out[11]= |

The following function has a removable discontinuity at *x*=3 and an infinite discontinuity at *x*=4:

In[13]:= |

Out[14]= |

Extend the definition at *x*=3 to make the extended function continuous there:

In[15]:= |

Out[15]= |

In[16]:= |

Out[17]= |

The extended function is actually differentiable at *x*=3:

In[18]:= |

Out[18]= |

The resource function EnhancedPlot produces a correct plot:

In[19]:= |

Out[19]= |

The function *g* is differentiable at *x=0* and PiecewiseD returns the correct value, 1. The function D, however, returns the value 0 for the derivative at *x=0*:

In[20]:= |

Out[22]= |

In[23]:= |

Out[23]= |

However, the derivative is not continuous:

In[24]:= |

Out[24]= |

This function is differentiable at *x*=0 and its derivative is continuous there:

In[25]:= |

Out[27]= |

In[28]:= |

Out[28]= |

Plot the result using the resource function EnhancedPlot:

In[29]:= |

Out[29]= |

A function with a singularity at *x*=-1 and *x*=1; PiecewiseD returns the correct result. Note that if this expression is simplified, the singularity at *x*=1 will be lost:

In[30]:= |

Out[30]= |

The resource function EnhancedPlot is able to produce a correct plot:

In[31]:= |

Out[31]= |

Extend the function so that it becomes continuous at -1 and 1:

In[32]:= |

Out[32]= |

In[33]:= |

The first and second derivatives are continuous at ±1:

In[34]:= |

Out[34]= |

In[35]:= |

Out[35]= |

Plot the extended function and its first two derivatives:

In[36]:= |

Out[36]= |

A classic example of a nonzero infinitely differentiable function all of whose derivatives at *x*=0 are 0 and hence all of whose Taylor polynomials based at 0 are the zero polynomial:

In[37]:= |

Out[39]= |

Illustrate with ResourceFunction["EnhancedPlot"]:

In[40]:= |

Out[40]= |

This work is licensed under a Creative Commons Attribution 4.0 International License