5.3.12 problem 19

Internal problem ID [1494]
Book : Elementary differential equations and boundary value problems, 11th ed., Boyce, DiPrima, Meade
Section : Chapter 6.2, The Laplace Transform. Solution of Initial Value Problems. page 255
Problem number : 19
Date solved : Tuesday, September 30, 2025 at 04:34:39 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+y&=\left \{\begin {array}{cc} t & 0\le t <1 \\ 2-t & 1\le t <2 \\ 0 & 2\le t <\infty \end {array}\right . \end{align*}

Using Laplace method With initial conditions

\begin{align*} y \left (0\right )&=1 \\ y^{\prime }\left (0\right )&=0 \\ \end{align*}
Maple. Time used: 0.474 (sec). Leaf size: 46
ode:=diff(diff(y(t),t),t)+y(t) = piecewise(0 <= t and t < 1,t,1 <= t and t < 2,2-t,2 <= t and t < infinity,0); 
ic:=[y(0) = 1, D(y)(0) = 0]; 
dsolve([ode,op(ic)],y(t),method='laplace');
 
\[ y = \cos \left (t \right )-\sin \left (t \right )+\left (\left \{\begin {array}{cc} t & t <1 \\ 2-t +2 \sin \left (t -1\right ) & t <2 \\ -\sin \left (t -2\right )+2 \sin \left (t -1\right ) & 2\le t \end {array}\right .\right ) \]
Mathematica. Time used: 0.035 (sec). Leaf size: 68
ode=D[y[t],{t,2}]+y[t]==Piecewise[{{t,0<t<1},{2-t,1<=t<2},{0,2<=t<Infinity}}]; 
ic={y[0]==1,Derivative[1][y][0] ==0}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\begin{align*} y(t)&\to \begin {array}{cc} \{ & \begin {array}{cc} \cos (t) & t\leq 0 \\ \cos (t)-4 \sin ^2\left (\frac {1}{2}\right ) \sin (1-t) & t>2 \\ t+\cos (t)-\sin (t) & 0<t\leq 1 \\ -t+\cos (t)-2 \sin (1-t)-\sin (t)+2 & \text {True} \\ \end {array} \\ \end {array} \end{align*}
Sympy. Time used: 0.569 (sec). Leaf size: 17
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(-Piecewise((t, (t > 0) & (t < 1)), (2 - t, (t >= 1) & (t < 2)), (2, (t >= 2) & (t < oo))) + y(t) + Derivative(y(t), (t, 2)),0) 
ics = {y(0): 1, Subs(Derivative(y(t), t), t, 0): 0} 
dsolve(ode,func=y(t),ics=ics)
 
\[ y{\left (t \right )} = C_{2} \cos {\left (t \right )} + \begin {cases} t & \text {for}\: t > 0 \wedge t < 1 \\2 - t & \text {for}\: t \geq 1 \wedge t < 2 \\2 & \text {for}\: t \geq 2 \wedge t < \infty \\\text {NaN} & \text {otherwise} \end {cases} \]