23.3.21 problem 9(b)

Internal problem ID [4162]
Book : Theory and solutions of Ordinary Differential equations, Donald Greenspan, 1960
Section : Chapter 4. The general linear differential equation of order n. Exercises at page 63
Problem number : 9(b)
Date solved : Sunday, March 30, 2025 at 02:41:19 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+9 y&=8 \sin \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.026 (sec). Leaf size: 19
ode:=diff(diff(y(x),x),x)+9*y(x) = 8*sin(x); 
ic:=y(1/2*Pi) = -1, D(y)(1/2*Pi) = 1; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = 2 \sin \left (3 x \right )+\frac {\cos \left (3 x \right )}{3}+\sin \left (x \right ) \]
Mathematica. Time used: 0.018 (sec). Leaf size: 22
ode=D[y[x],{x,2}]+9*y[x]==8*Sin[x]; 
ic={y[Pi/2]==-1,Derivative[1][y][Pi/2] ==1}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \sin (x)+2 \sin (3 x)+\frac {1}{3} \cos (3 x) \]
Sympy. Time used: 0.074 (sec). Leaf size: 19
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(9*y(x) - 8*sin(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 (x \right )} + 2 \sin {\left (3 x \right )} + \frac {\cos {\left (3 x \right )}}{3} \]