76.16.1 problem 14

Internal problem ID [17599]
Book : Differential equations. An introduction to modern methods and applications. James Brannan, William E. Boyce. Third edition. Wiley 2015
Section : Chapter 4. Second order linear equations. Section 4.6 (Forced vibrations, Frequency response, and Resonance). Problems at page 272
Problem number : 14
Date solved : Thursday, March 13, 2025 at 10:38:04 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

With initial conditions

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

Maple. Time used: 2.217 (sec). Leaf size: 45
ode:=diff(diff(y(t),t),t)+y(t) = piecewise(0 <= t and t <= Pi,A*t,Pi < t and t <= 2*Pi,A*(2*Pi-t),2*Pi < t,0); 
ic:=y(0) = 0, D(y)(0) = 0; 
dsolve([ode,ic],y(t), singsol=all);
 
\[ y = A \left (\left \{\begin {array}{cc} 0 & t <0 \\ t -\sin \left (t \right ) & t <\pi \\ -3 \sin \left (t \right )+2 \pi -t & t <2 \pi \\ -4 \sin \left (t \right ) & 2 \pi \le t \end {array}\right .\right ) \]
Mathematica. Time used: 0.039 (sec). Leaf size: 53
ode=D[y[t],{t,2}]+y[t]==Piecewise[{  {A*t,0<=t<=Pi}, {A*(2*Pi-t),Pi<t<=2*Pi},{0,t>2*Pi} }]; 
ic={y[0]==0,Derivative[1][y][0] == 0}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\[ y(t)\to \begin {array}{cc} \{ & \begin {array}{cc} 0 & t\leq 0 \\ A (t-\sin (t)) & 0<t\leq \pi \\ -A (t+3 \sin (t)-2 \pi ) & \pi <t\leq 2 \pi \\ -4 A \sin (t) & \text {True} \\ \end {array} \\ \end {array} \]
Sympy. Time used: 0.636 (sec). Leaf size: 26
from sympy import * 
t = symbols("t") 
A = symbols("A") 
y = Function("y") 
ode = Eq(-Piecewise((A*t, (t >= 0) & (t <= pi)), (A*(-t + 2*pi), (t > pi) & (t <= 2*pi)), (0, t > 2*pi)) + y(t) + Derivative(y(t), (t, 2)),0) 
ics = {y(0): 0, Subs(Derivative(y(t), t), t, 0): 0} 
dsolve(ode,func=y(t),ics=ics)
 
\[ y{\left (t \right )} = - A \sin {\left (t \right )} + \begin {cases} A t & \text {for}\: t \geq 0 \wedge t \leq \pi \\- A t + 2 \pi A & \text {for}\: t \leq 2 \pi \wedge t > \pi \\0 & \text {for}\: t > 2 \pi \\\text {NaN} & \text {otherwise} \end {cases} \]