40.7.4 problem 13

Internal problem ID [6694]
Book : Schaums Outline. Theory and problems of Differential Equations, 1st edition. Frank Ayres. McGraw Hill 1952
Section : Chapter 12. Linear equations of order n. Supplemetary problems. Page 81
Problem number : 13
Date solved : Sunday, March 30, 2025 at 11:19:56 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.002 (sec). Leaf size: 26
ode:=diff(diff(y(x),x),x)+9*y(x) = cos(x)*x; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (3 x \right ) c_2 +\cos \left (3 x \right ) c_1 +\frac {\sin \left (x \right )}{32}+\frac {x \cos \left (x \right )}{8} \]
Mathematica. Time used: 0.022 (sec). Leaf size: 32
ode=D[y[x],{x,2}]+9*y[x]==x*Cos[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{32} (\sin (x)+4 x \cos (x))+c_1 \cos (3 x)+c_2 \sin (3 x) \]
Sympy. Time used: 0.149 (sec). Leaf size: 27
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x*cos(x) + 9*y(x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} \sin {\left (3 x \right )} + C_{2} \cos {\left (3 x \right )} + \frac {x \cos {\left (x \right )}}{8} + \frac {\sin {\left (x \right )}}{32} \]