 piecewise - Maple Help

dsolve/piecewise

find solution of ordinary differential equations with piecewise coefficients Description

 • The dsolve function solves differential equations with piecewise coefficients. It solves general first order linear, linear constant coefficient with piecewise perturbation, and Riccati equations. It can handle some cases where the differential equation is solved by integration or variation of parameters.
 • The solutions are found in terms of distribution theory and translated into a piecewise expression.
 • You can verify a solution by substituting the solution into the equation. However, if the differential equation has jump discontinuities, the verification must be done in terms of Heaviside functions because the derivative at a discontinuous point is undefined in the piecewise function.
 • The theory is based on the dissertation Martin von Mohrenschildt. "Symbolic Solutions of Discontinuous Differential Equations." Swiss Federal Institute of Technology ETHZ No. 10768 Examples

First Order:

 > $\mathrm{FO}≔\frac{ⅆ}{ⅆx}y\left(x\right)+\mathrm{piecewise}\left(x<0,xx,0
 ${\mathrm{FO}}{≔}\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right){+}\left(\left\{\begin{array}{cc}{{x}}^{{2}}& {x}{<}{0}\\ {3}{}{x}& {0}{<}{x}\end{array}\right\\right){}{y}{}\left({x}\right){=}{0}$ (1)
 > $\mathrm{dsolve}\left(\mathrm{FO}\right)$
 ${y}{}\left({x}\right){=}\left\{\begin{array}{cc}{{ⅇ}}^{{-}\frac{{{x}}^{{3}}}{{3}}}{}\mathrm{c__1}& {x}{<}{0}\\ {{ⅇ}}^{{-}\frac{{3}{}{{x}}^{{2}}}{{2}}}{}\mathrm{c__1}& {0}{\le }{x}\end{array}\right\$ (2)

Linear with discontinuous perturbation:

 > $\mathrm{ode}≔\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}y\left(x\right)+y\left(x\right)=\mathrm{piecewise}\left(x<0,-1,x<1,1,x<2,\mathrm{sin}\left(x\right)\right)$
 ${\mathrm{ode}}{≔}\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right){+}{y}{}\left({x}\right){=}\left\{\begin{array}{cc}{-1}& {x}{<}{0}\\ {1}& {x}{<}{1}\\ {\mathrm{sin}}{}\left({x}\right)& {x}{<}{2}\end{array}\right\$ (3)
 > $\mathrm{sol}≔\mathrm{dsolve}\left(\mathrm{ode}\right)$
 ${\mathrm{sol}}{≔}{y}{}\left({x}\right){=}\left\{\begin{array}{cc}{\mathrm{sin}}{}\left({x}\right){}\mathrm{c__2}{+}{\mathrm{cos}}{}\left({x}\right){}\mathrm{c__1}{-}{1}& {x}{<}{0}\\ {\mathrm{sin}}{}\left({x}\right){}\mathrm{c__2}{+}{\mathrm{cos}}{}\left({x}\right){}\mathrm{c__1}{+}{1}{-}{2}{}{\mathrm{cos}}{}\left({x}\right)& {x}{<}{1}\\ {\mathrm{sin}}{}\left({x}\right){}\mathrm{c__2}{+}{\mathrm{cos}}{}\left({x}\right){}\mathrm{c__1}{-}\frac{{\mathrm{cos}}{}\left({x}\right){}{x}}{{2}}{+}{\mathrm{cos}}{}\left({-}{1}{+}{x}\right){+}\frac{{\mathrm{sin}}{}\left({-}{2}{+}{x}\right)}{{4}}{+}\frac{{\mathrm{sin}}{}\left({x}\right)}{{4}}{-}\frac{{3}{}{\mathrm{cos}}{}\left({x}\right)}{{2}}& {x}{<}{2}\\ {\mathrm{sin}}{}\left({x}\right){}\mathrm{c__2}{+}{\mathrm{cos}}{}\left({x}\right){}\mathrm{c__1}{+}{\mathrm{cos}}{}\left({-}{1}{+}{x}\right){+}\frac{{\mathrm{sin}}{}\left({-}{2}{+}{x}\right)}{{4}}{-}\frac{{5}{}{\mathrm{cos}}{}\left({x}\right)}{{2}}{-}\frac{{\mathrm{sin}}{}\left({x}{-}{4}\right)}{{4}}& {2}{\le }{x}\end{array}\right\$ (4)

Solutions can also be tested by using odetest.

 > $\mathrm{odetest}\left(\mathrm{sol},\mathrm{ode}\right)$
 $\left\{\begin{array}{cc}{\mathrm{undefined}}& {x}{=}{0}{\vee }{x}{=}{1}{\vee }{x}{=}{2}\\ {0}& {\mathrm{otherwise}}\end{array}\right\$ (5)

Non linear:

 > $\mathrm{ode}≔\frac{ⅆ}{ⅆx}y\left(x\right)=\mathrm{convert}\left(-\mathrm{signum}\left(x\right)\left|1-\left|x\right|\right|,\mathrm{piecewise}\right){y\left(x\right)}^{2}$
 ${\mathrm{ode}}{≔}\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right){=}\left(\left\{\begin{array}{cc}{-}{x}{-}{1}& {x}{\le }{-1}\\ {x}{+}{1}& {x}{<}{0}\\ {0}& {x}{=}{0}\\ {-}{1}{+}{x}& {x}{<}{1}\\ {1}{-}{x}& {1}{\le }{x}\end{array}\right\\right){}{{y}{}\left({x}\right)}^{{2}}$ (6)
 > $\mathrm{sol}≔\mathrm{dsolve}\left(\mathrm{ode}\right)$
 ${\mathrm{sol}}{≔}{y}{}\left({x}\right){=}\left\{\begin{array}{cc}{-}\frac{{2}}{{-}{{x}}^{{2}}{-}{2}{}\mathrm{c__1}{-}{2}{}{x}}& {x}{<}{-1}\\ {-}\frac{{2}}{{{x}}^{{2}}{-}{2}{}\mathrm{c__1}{+}{2}{}{x}{+}{2}}& {x}{<}{0}\\ {-}\frac{{2}}{{{x}}^{{2}}{-}{2}{}\mathrm{c__1}{-}{2}{}{x}{+}{2}}& {x}{<}{1}\\ {-}\frac{{2}}{{-}{{x}}^{{2}}{-}{2}{}\mathrm{c__1}{+}{2}{}{x}}& {1}{\le }{x}\end{array}\right\$ (7)
 > $\mathrm{odetest}\left(\mathrm{sol},\mathrm{ode}\right)$
 $\left\{\begin{array}{cc}{\mathrm{undefined}}& {x}{=}{0}\\ {0}& {\mathrm{otherwise}}\end{array}\right\$ (8)