dsolve/piecewise - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Mathematics : Differential Equations : dsolve : dsolve/piecewise

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:

 > FO:=diff(y(x),x)+piecewise(x<0,x*x,x>0,3*x)*y(x)=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)
 > dsolve(FO);
 ${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:

 > ode := diff(y(x),x\$2) + y(x) = piecewise(x<0,-1,x<1,1,x<2,sin(x));
 ${\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)
 > sol := dsolve(ode);
 ${\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.

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

Non linear:

 > ode := diff(y(x),x)=convert(-signum(x)*abs(1-abs(x)),piecewise)*y(x)^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)
 > sol := dsolve(ode);
 ${\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)
 > odetest(sol,ode);
 $\left\{\begin{array}{cc}{\mathrm{undefined}}& {x}{=}{0}\\ {0}& {\mathrm{otherwise}}\end{array}\right\$ (8)

 See Also