IVPs with Piecewise Coefficients

The differential equations that arise in modern applications often have discontinuous coefficients. DSolve can handle a wide variety of such ODEs with piecewise coefficients. Some of the functions used in these equations are UnitStep, Max, Min, Sign, and Abs. These functions and combinations of them can be converted into Piecewise objects.

This converts the given expression into a Piecewise expression.
In[1]:=
Click for copyable input
Out[1]=
Here is the general solution to a first-order ODE that contains UnitStep.
In[2]:=
Click for copyable input
Out[2]=
Here is the solution to the same ODE with an initial condition.
In[3]:=
Click for copyable input
In[4]:=
Click for copyable input
Out[4]=
The solution can be plotted in the usual way. Note that the solution is continuous but not differentiable at .
In[5]:=
Click for copyable input
Out[5]=
This verifies the solution.
In[6]:=
Click for copyable input
Out[6]=
Here is a piecewise ODE that has Max in its coefficients.
In[7]:=
Click for copyable input
Out[7]=
In[8]:=
Click for copyable input
Out[8]=

A piecewise ODE can be thought of as a collection of ODEs over disjoint intervals such that the expressions for the coefficients and the boundary conditions change from one interval to another. Thus, different intervals have different solutions, and the final solution for the ODE is obtained by patching together the solutions over the different intervals.

For this piecewise ODE, the expression for is obtained by patching together and . The boundary condition for the interval (-Infinity, 2] is simply , while the initial condition for the interval [2, Infinity) is (given by the final value for the solution over the first interval).
In[9]:=
Click for copyable input
Out[9]=
In[10]:=
Click for copyable input
Out[10]=
In[11]:=
Click for copyable input
Out[11]=

If there are a large number of discontinuities in a problem, it is convenient to use Piecewise directly in the formulation of the problem.

This second-order ODE contains a Piecewise term.
In[12]:=
Click for copyable input
In[13]:=
Click for copyable input
Out[13]=
This ODE contains the Clip function. The solutions are given in terms of Airy functions.
In[14]:=
Click for copyable input
In[15]:=
Click for copyable input
Out[15]=
New to Mathematica? Find your learning path »
Have a question? Ask support »