8.11.18 problem 33

Internal problem ID [886]
Book : Differential equations and linear algebra, 3rd ed., Edwards and Penney
Section : Section 5.5, Nonhomogeneous equations and undetermined coefficients Page 351
Problem number : 33
Date solved : Tuesday, March 04, 2025 at 11:58:04 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

With initial conditions

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

Maple. Time used: 0.006 (sec). Leaf size: 21
ode:=diff(diff(y(x),x),x)+9*y(x) = sin(2*x); 
ic:=y(0) = 1, D(y)(0) = 0; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = -\frac {2 \sin \left (3 x \right )}{15}+\cos \left (3 x \right )+\frac {\sin \left (2 x \right )}{5} \]
Mathematica. Time used: 0.023 (sec). Leaf size: 26
ode=D[y[x],{x,2}]+9*y[x]==Sin[2*x]; 
ic={y[0]==1,Derivative[1][y][0] ==0}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{5} \sin (2 x)-\frac {2}{15} \sin (3 x)+\cos (3 x) \]
Sympy. Time used: 0.094 (sec). Leaf size: 22
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(9*y(x) - sin(2*x) + Derivative(y(x), (x, 2)),0) 
ics = {y(0): 1, Subs(Derivative(y(x), x), x, 0): 0} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {\sin {\left (2 x \right )}}{5} - \frac {2 \sin {\left (3 x \right )}}{15} + \cos {\left (3 x \right )} \]