64.20.18 problem 18

Internal problem ID [13590]
Book : Differential Equations by Shepley L. Ross. Third edition. John Willey. New Delhi. 2004.
Section : Chapter 9, The Laplace transform. Section 9.3, Exercises page 452
Problem number : 18
Date solved : Monday, March 31, 2025 at 08:02:01 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+y&=\left \{\begin {array}{cc} t & 0<t <\pi \\ \pi & \pi <t \end {array}\right . \end{align*}

Using Laplace method With initial conditions

\begin{align*} y \left (0\right )&=2\\ y^{\prime }\left (0\right )&=3 \end{align*}

Maple. Time used: 0.271 (sec). Leaf size: 26
ode:=diff(diff(y(t),t),t)+y(t) = piecewise(0 < t and t < Pi,t,Pi < t,Pi); 
ic:=y(0) = 2, D(y)(0) = 3; 
dsolve([ode,ic],y(t),method='laplace');
 
\[ y = 2 \cos \left (t \right )+\left (\left \{\begin {array}{cc} t +2 \sin \left (t \right ) & t <\pi \\ \pi +\sin \left (t \right ) & \pi \le t \end {array}\right .\right ) \]
Mathematica. Time used: 0.032 (sec). Leaf size: 45
ode=D[y[t],{t,2}]+y[t]==Piecewise[{{t,0<t<Pi},{Pi,t>Pi}}]; 
ic={y[0]==2,Derivative[1][y][0]==3}; 
DSolve[{ode,ic},{y[t]},t,IncludeSingularSolutions->True]
 
\[ y(t)\to \begin {array}{cc} \{ & \begin {array}{cc} 2 \cos (t)+3 \sin (t) & t\leq 0 \\ t+2 \cos (t)+2 \sin (t) & 0<t\leq \pi \\ 2 \cos (t)+\sin (t)+\pi & \text {True} \\ \end {array} \\ \end {array} \]
Sympy. Time used: 0.419 (sec). Leaf size: 17
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(-Piecewise((t, (t > 0) & (t < pi)), (pi, t > pi)) + y(t) + Derivative(y(t), (t, 2)),0) 
ics = {y(0): 2, Subs(Derivative(y(t), t), t, 0): 3} 
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 < \pi \\\pi & \text {for}\: t > \pi \\\text {NaN} & \text {otherwise} \end {cases} + 3 \sin {\left (t \right )} \]