76.16.3 problem 17

Internal problem ID [17601]
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 : 17
Date solved : Thursday, March 13, 2025 at 10:39:27 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+y&=2 \cos \left (w t \right ) \end{align*}

With initial conditions

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

Maple. Time used: 0.030 (sec). Leaf size: 23
ode:=diff(diff(y(t),t),t)+y(t) = 2*cos(w*t); 
ic:=y(0) = 0, D(y)(0) = 0; 
dsolve([ode,ic],y(t), singsol=all);
 
\[ y = \frac {2 \cos \left (t \right )-2 \cos \left (w t \right )}{w^{2}-1} \]
Mathematica. Time used: 0.019 (sec). Leaf size: 23
ode=D[y[t],{t,2}]+y[t]==2*Cos[w*t]; 
ic={y[0]==0,Derivative[1][y][0] == 0}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\[ y(t)\to \frac {2 (\cos (t)-\cos (t w))}{w^2-1} \]
Sympy. Time used: 0.088 (sec). Leaf size: 24
from sympy import * 
t = symbols("t") 
w = symbols("w") 
y = Function("y") 
ode = Eq(y(t) - 2*cos(t*w) + 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 )} = \frac {2 \cos {\left (t \right )}}{w^{2} - 1} - \frac {2 \cos {\left (t w \right )}}{w^{2} - 1} \]