76.15.13 problem 13

Internal problem ID [17583]
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.5 (Nonhomogeneous Equations, Method of Undetermined Coefficients). Problems at page 260
Problem number : 13
Date solved : Monday, March 31, 2025 at 04:18:16 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.005 (sec). Leaf size: 34
ode:=diff(diff(u(t),t),t)+w__0^2*u(t) = cos(w*t); 
dsolve(ode,u(t), singsol=all);
 
\[ u = \sin \left (w_{0} t \right ) c_2 +\cos \left (w_{0} t \right ) c_1 -\frac {\cos \left (w t \right )}{w^{2}-w_{0}^{2}} \]
Mathematica. Time used: 0.171 (sec). Leaf size: 49
ode=D[u[t],{t,2}]+w0^2*u[t]==Cos[w*t]; 
ic={}; 
DSolve[{ode,ic},u[t],t,IncludeSingularSolutions->True]
 
\[ u(t)\to \frac {\cos (t w)-\left (w^2-\text {w0}^2\right ) (c_1 \cos (t \text {w0})+c_2 \sin (t \text {w0}))}{(\text {w0}-w) (w+\text {w0})} \]
Sympy. Time used: 0.107 (sec). Leaf size: 31
from sympy import * 
t = symbols("t") 
w = symbols("w") 
w__0 = symbols("w__0") 
u = Function("u") 
ode = Eq(w__0**2*u(t) - cos(t*w) + Derivative(u(t), (t, 2)),0) 
ics = {} 
dsolve(ode,func=u(t),ics=ics)
 
\[ u{\left (t \right )} = C_{1} e^{- i t w^{0}} + C_{2} e^{i t w^{0}} - \frac {\cos {\left (t w \right )}}{w^{2} - \left (w^{0}\right )^{2}} \]