15.2 problem 4 (b)

15.2.1 Existence and uniqueness analysis
15.2.2 Maple step by step solution

Internal problem ID [12807]
Internal file name [OUTPUT/11460_Saturday_November_04_2023_08_47_25_AM_68786493/index.tex]

Book: Ordinary Differential Equations by Charles E. Roberts, Jr. CRC Press. 2010
Section: Chapter 5. The Laplace Transform Method. Exercises 5.4, page 265
Problem number: 4 (b).
ODE order: 2.
ODE degree: 1.

The type(s) of ODE detected by this program : "second_order_laplace", "second_order_linear_constant_coeff"

Maple gives the following as the ode type

[[_2nd_order, _linear, _nonhomogeneous]]

\[ \boxed {y^{\prime \prime }-y^{\prime }-2 y=\left \{\begin {array}{cc} 1 & 2\le x <4 \\ 0 & \operatorname {otherwise} \end {array}\right .} \] With initial conditions \begin {align*} [y \left (0\right ) = 0, y^{\prime }\left (0\right ) = 1] \end {align*}

15.2.1 Existence and uniqueness analysis

This is a linear ODE. In canonical form it is written as \begin {align*} y^{\prime \prime } + p(x)y^{\prime } + q(x) y &= F \end {align*}

Where here \begin {align*} p(x) &=-1\\ q(x) &=-2\\ F &=\left \{\begin {array}{cc} 0 & x <2 \\ 1 & x <4 \\ 0 & 4\le x \end {array}\right . \end {align*}

Hence the ode is \begin {align*} y^{\prime \prime }-y^{\prime }-2 y = \left \{\begin {array}{cc} 0 & x <2 \\ 1 & x <4 \\ 0 & 4\le x \end {array}\right . \end {align*}

The domain of \(p(x)=-1\) is \[ \{-\infty

Solving using the Laplace transform method. Let \begin {align*} \mathcal {L}\left (y\right ) =Y(s) \end {align*}

Taking the Laplace transform of the ode and using the relations that \begin {align*} \mathcal {L}\left (y^{\prime }\right ) &= s Y(s) - y \left (0\right )\\ \mathcal {L}\left (y^{\prime \prime }\right ) &= s^2 Y(s) - y'(0) - s y \left (0\right ) \end {align*}

The given ode now becomes an algebraic equation in the Laplace domain \begin {align*} s^{2} Y \left (s \right )-y^{\prime }\left (0\right )-s y \left (0\right )-s Y \left (s \right )+y \left (0\right )-2 Y \left (s \right ) = \frac {{\mathrm e}^{-2 s}-{\mathrm e}^{-4 s}}{s}\tag {1} \end {align*}

But the initial conditions are \begin {align*} y \left (0\right )&=0\\ y'(0) &=1 \end {align*}

Substituting these initial conditions in above in Eq (1) gives \begin {align*} s^{2} Y \left (s \right )-1-s Y \left (s \right )-2 Y \left (s \right ) = \frac {{\mathrm e}^{-2 s}-{\mathrm e}^{-4 s}}{s} \end {align*}

Solving the above equation for \(Y(s)\) results in \begin {align*} Y(s) = \frac {{\mathrm e}^{-2 s}-{\mathrm e}^{-4 s}+s}{s \left (s^{2}-s -2\right )} \end {align*}

Taking the inverse Laplace transform gives \begin {align*} y&= \mathcal {L}^{-1}\left (Y(s)\right )\\ &= \mathcal {L}^{-1}\left (\frac {{\mathrm e}^{-2 s}-{\mathrm e}^{-4 s}+s}{s \left (s^{2}-s -2\right )}\right )\\ &= -\frac {{\mathrm e}^{-x}}{3}+\frac {{\mathrm e}^{2 x}}{3}+\frac {{\mathrm e}^{2 x -8} \left (-1+\operatorname {Heaviside}\left (4-x \right )\right )}{6}+\frac {\left (1-\operatorname {Heaviside}\left (2-x \right )\right ) {\mathrm e}^{2 x -4}}{6}-\frac {\operatorname {Heaviside}\left (x -2\right ) \left (3-2 \,{\mathrm e}^{2-x}\right )}{6}+\frac {\operatorname {Heaviside}\left (x -4\right ) \left (3-2 \,{\mathrm e}^{4-x}\right )}{6} \end {align*}

Converting the above solution to piecewise it becomes \[ y = \left \{\begin {array}{cc} -\frac {{\mathrm e}^{-x}}{3}+\frac {{\mathrm e}^{2 x}}{3} & x <2 \\ -\frac {{\mathrm e}^{-2}}{3}+\frac {{\mathrm e}^{4}}{3}-\frac {1}{6} & x =2 \\ -\frac {{\mathrm e}^{-x}}{3}+\frac {{\mathrm e}^{2 x}}{3}+\frac {{\mathrm e}^{2 x -4}}{6}-\frac {1}{2}+\frac {{\mathrm e}^{2-x}}{3} & x <4 \\ -\frac {{\mathrm e}^{-4}}{3}+\frac {{\mathrm e}^{8}}{3}+\frac {{\mathrm e}^{4}}{6}+\frac {{\mathrm e}^{-2}}{3}-\frac {1}{3} & x =4 \\ -\frac {{\mathrm e}^{-x}}{3}+\frac {{\mathrm e}^{2 x}}{3}-\frac {{\mathrm e}^{2 x -8}}{6}+\frac {{\mathrm e}^{2 x -4}}{6}+\frac {{\mathrm e}^{2-x}}{3}-\frac {{\mathrm e}^{4-x}}{3} & 4

Summary

The solution(s) found are the following \begin{align*} \tag{1} y &= \frac {\left (\left \{\begin {array}{cc} -{\mathrm e}^{-x}+{\mathrm e}^{2 x} & x <2 \\ -\frac {1}{2}+{\mathrm e}^{4}-{\mathrm e}^{-2} & x &=2 \\ -{\mathrm e}^{-x}+{\mathrm e}^{2 x}+\frac {{\mathrm e}^{2 x -4}}{2}-\frac {3}{2}+{\mathrm e}^{2-x} & x <4 \\ \frac {\left (2 \,{\mathrm e}^{12}+{\mathrm e}^{8}-2 \,{\mathrm e}^{4}+2 \,{\mathrm e}^{2}-2\right ) {\mathrm e}^{-4}}{2} & x &=4 \\ -{\mathrm e}^{-x}+{\mathrm e}^{2 x}-\frac {{\mathrm e}^{2 x -8}}{2}+\frac {{\mathrm e}^{2 x -4}}{2}+{\mathrm e}^{2-x}-{\mathrm e}^{4-x} & 4

Verification of solutions

\[ y = \frac {\left (\left \{\begin {array}{cc} -{\mathrm e}^{-x}+{\mathrm e}^{2 x} & x <2 \\ -\frac {1}{2}+{\mathrm e}^{4}-{\mathrm e}^{-2} & x =2 \\ -{\mathrm e}^{-x}+{\mathrm e}^{2 x}+\frac {{\mathrm e}^{2 x -4}}{2}-\frac {3}{2}+{\mathrm e}^{2-x} & x <4 \\ \frac {\left (2 \,{\mathrm e}^{12}+{\mathrm e}^{8}-2 \,{\mathrm e}^{4}+2 \,{\mathrm e}^{2}-2\right ) {\mathrm e}^{-4}}{2} & x =4 \\ -{\mathrm e}^{-x}+{\mathrm e}^{2 x}-\frac {{\mathrm e}^{2 x -8}}{2}+\frac {{\mathrm e}^{2 x -4}}{2}+{\mathrm e}^{2-x}-{\mathrm e}^{4-x} & 4

15.2.2 Maple step by step solution

\[ \begin {array}{lll} & {} & \textrm {Let's solve}\hspace {3pt} \\ {} & {} & \left [y^{\prime \prime }-y^{\prime }-2 y=\left \{\begin {array}{cc} 0 & x <2 \\ 1 & x <4 \\ 0 & 4\le x \end {array}\right ., y \left (0\right )=0, y^{\prime }{\raise{-0.36em}{\Big |}}{\mstack {}{_{\left \{x \hiderel {=}0\right \}}}}=1\right ] \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 2 \\ {} & {} & y^{\prime \prime } \\ \bullet & {} & \textrm {Characteristic polynomial of homogeneous ODE}\hspace {3pt} \\ {} & {} & r^{2}-r -2=0 \\ \bullet & {} & \textrm {Factor the characteristic polynomial}\hspace {3pt} \\ {} & {} & \left (r +1\right ) \left (r -2\right )=0 \\ \bullet & {} & \textrm {Roots of the characteristic polynomial}\hspace {3pt} \\ {} & {} & r =\left (-1, 2\right ) \\ \bullet & {} & \textrm {1st solution of the homogeneous ODE}\hspace {3pt} \\ {} & {} & y_{1}\left (x \right )={\mathrm e}^{-x} \\ \bullet & {} & \textrm {2nd solution of the homogeneous ODE}\hspace {3pt} \\ {} & {} & y_{2}\left (x \right )={\mathrm e}^{2 x} \\ \bullet & {} & \textrm {General solution of the ODE}\hspace {3pt} \\ {} & {} & y=c_{1} y_{1}\left (x \right )+c_{2} y_{2}\left (x \right )+y_{p}\left (x \right ) \\ \bullet & {} & \textrm {Substitute in solutions of the homogeneous ODE}\hspace {3pt} \\ {} & {} & y={\mathrm e}^{-x} c_{1} +c_{2} {\mathrm e}^{2 x}+y_{p}\left (x \right ) \\ \square & {} & \textrm {Find a particular solution}\hspace {3pt} y_{p}\left (x \right )\hspace {3pt}\textrm {of the ODE}\hspace {3pt} \\ {} & \circ & \textrm {Use variation of parameters to find}\hspace {3pt} y_{p}\hspace {3pt}\textrm {here}\hspace {3pt} f \left (x \right )\hspace {3pt}\textrm {is the forcing function}\hspace {3pt} \\ {} & {} & \left [y_{p}\left (x \right )=-y_{1}\left (x \right ) \left (\int \frac {y_{2}\left (x \right ) f \left (x \right )}{W \left (y_{1}\left (x \right ), y_{2}\left (x \right )\right )}d x \right )+y_{2}\left (x \right ) \left (\int \frac {y_{1}\left (x \right ) f \left (x \right )}{W \left (y_{1}\left (x \right ), y_{2}\left (x \right )\right )}d x \right ), f \left (x \right )=\left \{\begin {array}{cc} 0 & x <2 \\ 1 & x <4 \\ 0 & 4\le x \end {array}\right .\right ] \\ {} & \circ & \textrm {Wronskian of solutions of the homogeneous equation}\hspace {3pt} \\ {} & {} & W \left (y_{1}\left (x \right ), y_{2}\left (x \right )\right )=\left [\begin {array}{cc} {\mathrm e}^{-x} & {\mathrm e}^{2 x} \\ -{\mathrm e}^{-x} & 2 \,{\mathrm e}^{2 x} \end {array}\right ] \\ {} & \circ & \textrm {Compute Wronskian}\hspace {3pt} \\ {} & {} & W \left (y_{1}\left (x \right ), y_{2}\left (x \right )\right )=3 \,{\mathrm e}^{x} \\ {} & \circ & \textrm {Substitute functions into equation for}\hspace {3pt} y_{p}\left (x \right ) \\ {} & {} & y_{p}\left (x \right )=-{\mathrm e}^{-x} \left (\int \left (\left \{\begin {array}{cc} 0 & x <2 \\ \frac {{\mathrm e}^{x}}{3} & x <4 \\ 0 & 4\le x \end {array}\right .\right )d x \right )+{\mathrm e}^{2 x} \left (\int \left (\left \{\begin {array}{cc} 0 & x <2 \\ \frac {{\mathrm e}^{-2 x}}{3} & x <4 \\ 0 & 4\le x \end {array}\right .\right )d x \right ) \\ {} & \circ & \textrm {Compute integrals}\hspace {3pt} \\ {} & {} & y_{p}\left (x \right )=\frac {\left (\left \{\begin {array}{cc} 0 & x \le 2 \\ {\mathrm e}^{2 x -4}-3+2 \,{\mathrm e}^{2-x} & x \le 4 \\ -{\mathrm e}^{2 x -8}+{\mathrm e}^{2 x -4}+2 \,{\mathrm e}^{2-x}-2 \,{\mathrm e}^{4-x} & 4

Maple trace

`Methods for second order ODEs: 
--- Trying classification methods --- 
trying a quadrature 
trying high order exact linear fully integrable 
trying differential order: 2; linear nonhomogeneous with symmetry [0,1] 
trying a double symmetry of the form [xi=0, eta=F(x)] 
-> Try solving first the homogeneous part of the ODE 
   checking if the LODE has constant coefficients 
   <- constant coefficients successful 
<- solving first the homogeneous part of the ODE successful`
 

Solution by Maple

Time used: 8.969 (sec). Leaf size: 136

dsolve([diff(y(x),x$2)-diff(y(x),x)-2*y(x)=piecewise(2<=x and x<4,1,true,0),y(0) = 0, D(y)(0) = 1],y(x), singsol=all)
 

\[ y \left (x \right ) = \frac {\left (\left \{\begin {array}{cc} -{\mathrm e}^{-x}+{\mathrm e}^{2 x} & x <2 \\ -\frac {1}{2}-{\mathrm e}^{-2}+{\mathrm e}^{4} & x =2 \\ -{\mathrm e}^{-x}+{\mathrm e}^{2 x}-\frac {3}{2}+{\mathrm e}^{2-x}+\frac {{\mathrm e}^{2 x -4}}{2} & x <4 \\ \frac {\left (2 \,{\mathrm e}^{12}+{\mathrm e}^{8}-2 \,{\mathrm e}^{4}+2 \,{\mathrm e}^{2}-2\right ) {\mathrm e}^{-4}}{2} & x =4 \\ -{\mathrm e}^{-x}+{\mathrm e}^{2 x}-{\mathrm e}^{4-x}+{\mathrm e}^{2-x}-\frac {{\mathrm e}^{2 x -8}}{2}+\frac {{\mathrm e}^{2 x -4}}{2} & 4

Solution by Mathematica

Time used: 0.068 (sec). Leaf size: 127

DSolve[{y''[x]-y'[x]-2*y[x]==Piecewise[{ {1,2<=x<4},{0,True}}],{y[0]==0,y'[0]==1}},y[x],x,IncludeSingularSolutions -> True]
 

\[ y(x)\to \begin {array}{cc} \{ & \begin {array}{cc} \frac {1}{3} e^{-x} \left (-1+e^{3 x}\right ) & x\leq 2 \\ \frac {1}{6} e^{-x-4} \left (-2 e^4+2 e^6+e^{3 x}-3 e^{x+4}+2 e^{3 x+4}\right ) & 2