26.8.23 problem Exercise 21.31, page 231

Internal problem ID [7107]
Book : Ordinary Differential Equations, By Tenenbaum and Pollard. Dover, NY 1963
Section : Chapter 4. Higher order linear differential equations. Lesson 21. Undetermined Coefficients
Problem number : Exercise 21.31, page 231
Date solved : Tuesday, September 30, 2025 at 04:21:32 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+9 y&=8 \cos \left (x \right ) \end{align*}

With initial conditions

\begin{align*} y \left (\frac {\pi }{2}\right )&=-1 \\ y^{\prime }\left (\frac {\pi }{2}\right )&=1 \\ \end{align*}
Maple. Time used: 0.027 (sec). Leaf size: 17
ode:=diff(diff(y(x),x),x)+9*y(x) = 8*cos(x); 
ic:=[y(1/2*Pi) = -1, D(y)(1/2*Pi) = 1]; 
dsolve([ode,op(ic)],y(x), singsol=all);
 
\[ y = \sin \left (3 x \right )+\frac {2 \cos \left (3 x \right )}{3}+\cos \left (x \right ) \]
Mathematica. Time used: 0.012 (sec). Leaf size: 20
ode=D[y[x],{x,2}]+9*y[x]==8*Cos[x]; 
ic={y[Pi/2]==-1,Derivative[1][y][Pi/2]==1}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \sin (3 x)+\cos (x)+\frac {2}{3} \cos (3 x) \end{align*}
Sympy. Time used: 0.045 (sec). Leaf size: 19
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(9*y(x) - 8*cos(x) + Derivative(y(x), (x, 2)),0) 
ics = {y(pi/2): -1, Subs(Derivative(y(x), x), x, pi/2): 1} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \sin {\left (3 x \right )} + \cos {\left (x \right )} + \frac {2 \cos {\left (3 x \right )}}{3} \]