74.21.4 problem 18

Internal problem ID [16563]
Book : INTRODUCTORY DIFFERENTIAL EQUATIONS. Martha L. Abell, James P. Braselton. Fourth edition 2014. ElScAe. 2014
Section : Chapter 5. Applications of Higher Order Equations. Exercises 5.3, page 249
Problem number : 18
Date solved : Thursday, March 13, 2025 at 08:21:04 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

With initial conditions

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

Maple. Time used: 4.704 (sec). Leaf size: 180
ode:=diff(diff(x(t),t),t)+4*diff(x(t),t)+13*x(t) = piecewise(0 <= t and t < Pi,1,Pi <= t and t < 2*Pi,1-t,2*Pi <= t,0); 
ic:=x(0) = 0, D(x)(0) = 0; 
dsolve([ode,ic],x(t), singsol=all);
 
\[ x \left (t \right ) = -\frac {\left (\left \{\begin {array}{cc} 0 & t <0 \\ -3+\left (2 \sin \left (3 t \right )+3 \cos \left (3 t \right )\right ) {\mathrm e}^{-2 t} & t <\pi \\ \frac {\left (\left (39 \pi -12\right ) \cos \left (3 t \right )+\sin \left (3 t \right ) \left (26 \pi +5\right )\right ) {\mathrm e}^{2 \pi -2 t}}{13}+3 \,{\mathrm e}^{-2 t} \cos \left (3 t \right )+2 \,{\mathrm e}^{-2 t} \sin \left (3 t \right )+3 t -\frac {51}{13} & t <2 \pi \\ \frac {\left (\left (39 \pi -12\right ) \cos \left (3 t \right )+\sin \left (3 t \right ) \left (26 \pi +5\right )\right ) {\mathrm e}^{2 \pi -2 t}}{13}+\frac {\left (\left (78 \pi -51\right ) \cos \left (3 t \right )+\sin \left (3 t \right ) \left (52 \pi -21\right )\right ) {\mathrm e}^{4 \pi -2 t}}{13}+3 \,{\mathrm e}^{-2 t} \left (\cos \left (3 t \right )+\frac {2 \sin \left (3 t \right )}{3}\right ) & 2 \pi \le t \end {array}\right .\right )}{39} \]
Mathematica. Time used: 0.046 (sec). Leaf size: 60
ode=D[x[t],{t,2}]+x[t]==Piecewise[{{1,0<=t<Pi},{1-t,Pi<=t<2*Pi},{0,t>=2*Pi}}]; 
ic={x[0]==0,Derivative[1][x][0 ]==0}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\[ x(t)\to \begin {array}{cc} \{ & \begin {array}{cc} 0 & t\leq 0 \\ 1-\cos (t) & 0<t\leq \pi \\ -t-(1+\pi ) \cos (t)-\sin (t)+1 & \pi <t\leq 2 \pi \\ -3 \pi \cos (t)-2 \sin (t) & \text {True} \\ \end {array} \\ \end {array} \]
Sympy. Time used: 0.527 (sec). Leaf size: 17
from sympy import * 
t = symbols("t") 
x = Function("x") 
ode = Eq(-Piecewise((1, (t >= 0) & (t < pi)), (1 - t, (t >= pi) & (t <= 2*pi)), (0, t >= 2*pi)) + x(t) + Derivative(x(t), (t, 2)),0) 
ics = {x(0): 0, Subs(Derivative(x(t), t), t, 0): 0} 
dsolve(ode,func=x(t),ics=ics)
 
\[ x{\left (t \right )} = \begin {cases} 1 & \text {for}\: t \geq 0 \wedge t < \pi \\1 - t & \text {for}\: t \geq \pi \wedge t \leq 2 \pi \\0 & \text {for}\: t > 2 \pi \\\text {NaN} & \text {otherwise} \end {cases} - \cos {\left (t \right )} \]