72.19.8 problem 34

Internal problem ID [14895]
Book : DIFFERENTIAL EQUATIONS by Paul Blanchard, Robert L. Devaney, Glen R. Hall. 4th edition. Brooks/Cole. Boston, USA. 2012
Section : Chapter 6. Laplace transform. Section 6.3 page 600
Problem number : 34
Date solved : Monday, March 31, 2025 at 01:01:42 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Using Laplace method With initial conditions

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

Maple. Time used: 0.339 (sec). Leaf size: 49
ode:=diff(diff(y(t),t),t)+3*y(t) = piecewise(0 <= t and t < 1,t,1 <= t,1); 
ic:=y(0) = 2, D(y)(0) = 0; 
dsolve([ode,ic],y(t),method='laplace');
 
\[ y = 2 \cos \left (\sqrt {3}\, t \right )-\frac {\sqrt {3}\, \sin \left (\sqrt {3}\, t \right )}{9}+\frac {\left (\left \{\begin {array}{cc} t & t <1 \\ 1+\frac {\sin \left (\sqrt {3}\, \left (t -1\right )\right ) \sqrt {3}}{3} & 1\le t \end {array}\right .\right )}{3} \]
Mathematica. Time used: 0.05 (sec). Leaf size: 108
ode=D[y[t],{t,2}]+3*y[t]==Piecewise[{{t,0<=t<1},{1,t>=1}}]; 
ic={y[0]==2,Derivative[1][y][0] ==0}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\[ y(t)\to \begin {array}{cc} \{ & \begin {array}{cc} 2 \cos \left (\sqrt {3} t\right ) & t\leq 0 \\ \frac {1}{9} \left (3 t+18 \cos \left (\sqrt {3} t\right )-\sqrt {3} \sin \left (\sqrt {3} t\right )\right ) & 0<t\leq 1 \\ \frac {1}{9} \left (18 \cos \left (\sqrt {3} t\right )+\sqrt {3} \sin \left (\sqrt {3} (t-1)\right )-\sqrt {3} \sin \left (\sqrt {3} t\right )+3\right ) & \text {True} \\ \end {array} \\ \end {array} \]
Sympy. Time used: 0.481 (sec). Leaf size: 36
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(-Piecewise((t, (t >= 0) & (t < 1)), (1, t >= 1)) + 3*y(t) + Derivative(y(t), (t, 2)),0) 
ics = {y(0): 2, Subs(Derivative(y(t), t), t, 0): 0} 
dsolve(ode,func=y(t),ics=ics)
 
\[ y{\left (t \right )} = \begin {cases} \frac {t}{3} & \text {for}\: t \geq 0 \wedge t < 1 \\\frac {1}{3} & \text {for}\: t \geq 1 \\\text {NaN} & \text {otherwise} \end {cases} - \frac {\sqrt {3} \sin {\left (\sqrt {3} t \right )}}{9} + 2 \cos {\left (\sqrt {3} t \right )} \]