57.10.2 problem 7(a)

Internal problem ID [14433]
Book : A First Course in Differential Equations by J. David Logan. Third Edition. Springer-Verlag, NY. 2015.
Section : Chapter 2, Second order linear equations. Section 2.3.2 Resonance Exercises page 114
Problem number : 7(a)
Date solved : Thursday, October 02, 2025 at 09:37:08 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

With initial conditions

\begin{align*} x \left (0\right )&=0 \\ x^{\prime }\left (0\right )&=0 \\ \end{align*}
Maple. Time used: 0.029 (sec). Leaf size: 27
ode:=diff(diff(x(t),t),t)+w^2*x(t) = cos(beta*t); 
ic:=[x(0) = 0, D(x)(0) = 0]; 
dsolve([ode,op(ic)],x(t), singsol=all);
 
\[ x = \frac {\cos \left (w t \right )-\cos \left (\beta t \right )}{\beta ^{2}-w^{2}} \]
Mathematica. Time used: 0.123 (sec). Leaf size: 28
ode=D[x[t],{t,2}]+w^2*x[t]==Cos[\[Beta]*t]; 
ic={x[0]==0,Derivative[1][x][0 ]==0}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\begin{align*} x(t)&\to \frac {\cos (\beta t)-\cos (t w)}{w^2-\beta ^2} \end{align*}
Sympy. Time used: 0.086 (sec). Leaf size: 49
from sympy import * 
t = symbols("t") 
BETA = symbols("BETA") 
w = symbols("w") 
x = Function("x") 
ode = Eq(w**2*x(t) - cos(BETA*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 )} = \frac {\cos {\left (\beta t \right )}}{- \beta ^{2} + w^{2}} - \frac {e^{i t w}}{- 2 \beta ^{2} + 2 w^{2}} - \frac {e^{- i t w}}{- 2 \beta ^{2} + 2 w^{2}} \]