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}≔\mathrm{diff}\left(y\left(x\right),x\right)+\left(\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{_C1}}& {x}{<}{0}\\ {{ⅇ}}^{{-}\frac{{3}{}{{x}}^{{2}}}{{2}}}{}{\mathrm{_C1}}& {0}{\le }{x}\end{array}\right\$ (2)

Linear with discontinuous perturbation:

 > $\mathrm{ode}≔\mathrm{diff}\left(y\left(x\right),\mathrm{}\left(x,2\right)\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{_C2}}{+}{\mathrm{cos}}{}\left({x}\right){}{\mathrm{_C1}}{-}{1}& {x}{<}{0}\\ {\mathrm{sin}}{}\left({x}\right){}{\mathrm{_C2}}{+}{\mathrm{cos}}{}\left({x}\right){}{\mathrm{_C1}}{+}{1}{-}{2}{}{\mathrm{cos}}{}\left({x}\right)& {x}{<}{1}\\ {\mathrm{sin}}{}\left({x}\right){}{\mathrm{_C2}}{+}{\mathrm{cos}}{}\left({x}\right){}{\mathrm{_C1}}{-}\frac{{\mathrm{cos}}{}\left({x}\right){}{x}}{{2}}{+}{\mathrm{cos}}{}\left({-}{1}{+}{x}\right){+}\frac{{\mathrm{sin}}{}\left({-}{2}{+}{x}\right)}{{4}}{-}\frac{{3}{}{\mathrm{cos}}{}\left({x}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left({x}\right)}{{4}}& {x}{<}{2}\\ {\mathrm{sin}}{}\left({x}\right){}{\mathrm{_C2}}{+}{\mathrm{cos}}{}\left({x}\right){}{\mathrm{_C1}}{+}{\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}≔\mathrm{diff}\left(y\left(x\right),x\right)=\mathrm{convert}\left(-\mathrm{signum}\left(x\right)\mathrm{abs}\left(1-\mathrm{abs}\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{_C1}}{-}{2}{}{x}}& {x}{<}{-1}\\ {-}\frac{{2}}{{{x}}^{{2}}{-}{2}{}{\mathrm{_C1}}{+}{2}{}{x}{+}{2}}& {x}{<}{0}\\ {-}\frac{{2}}{{{x}}^{{2}}{-}{2}{}{\mathrm{_C1}}{-}{2}{}{x}{+}{2}}& {x}{<}{1}\\ {-}\frac{{2}}{{-}{{x}}^{{2}}{-}{2}{}{\mathrm{_C1}}{+}{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)