Investigating Differentiability 
of Piecewise Functions

This is a collection of examples suitable for in-class demonstration and/or individual student exploration. 

The examples are built into a Java applet from the Java Components for Mathematics collection.   A picture of the applet grapher is shown below.

To access the built-in example functions, use the pull-down menu in the applet to select the appropriate example.

In this demo, the focus is on constructing differentiable piecewise functions.  Thus the object is to move the appropriate sliders to 

  • Match the pieces of the function (graphed in magenta), AND

  • Match the pieces of the derivative (graphed in green)

as shown in the next picture.

The functionality of the applet allows for user input of piecewise functions that can have as many as 6 parameters. The syntax for entering piecewise functions is illustrated using the following examples.

The function

would be entered as


The function

would be entered as

(x<-2)?3*x+2:(-2<=x AND x < 1)?2*x^2-x+1:(x>=1)?x-1.

In this applet, the function and its derivative are plotted on the same graph.  Enter the function as f1(x) and its derivative as f2(x).  The applet does not actually compute the derivative.

Note that axis limits can be adjusted as necessary. 

Endpoints are not displayed by the Java applet so it is important to discuss endpoint inclusion/exclusion as appropriate as well as behavior at the break points in the domain.

The syntax for entering functions is quite cumbersome and may be confusing for students.  Use with caution and ample explanation if you choose to use the applet for individual student work.  If you have Excel available, the Excel spreadsheet is much more user-friendly for individual student work.

If you provide the applet for student assignments/experimentation, please point out what the appropriate parameters are for the particular example.  These can be observed from the function coding, however, they are also noted in the table below.  If a parameter is NOT relevant in a particular example, the slider will have no effect.

The built-in functions are given below.  The correct values of the parameters are whole number multiples of -0.25 or 0.25 except in the cases that the parameters can have any value (e.g. Example 10).

Example 1: 


Parameters are k and m.

Example 2: 

Parameters are a and b.
Example 3:  

Parameters are a and b.
Example 4:  

Parameters are k and c.
Example 5:  

Parameters are m, b, and c.
Example 6:  

Parameters are k, m, and b.
Example 7:  

Parameters are k, m, and b.
Example 8: 


Parameters are k and m.
Example 9:  

Parameters are k and a.
Example 10: 

Parameters are a, b, and c.

The Java applet is part of the Java Components for Math collection, developed by David Eck ( project was supported by NSF grant number DUE-9950473