6.10.17 problem 17

Internal problem ID [1821]
Book : Elementary differential equations with boundary value problems. William F. Trench. Brooks/Cole 2001
Section : Chapter 5 linear second order equations. Section 5.7 Variation of Parameters. Page 262
Problem number : 17
Date solved : Tuesday, September 30, 2025 at 05:20:01 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} x^{2} y^{\prime \prime }-2 x y^{\prime }+\left (x^{2}+2\right ) y&=x^{3} \cos \left (x \right ) \end{align*}
Maple. Time used: 0.005 (sec). Leaf size: 21
ode:=x^2*diff(diff(y(x),x),x)-2*x*diff(y(x),x)+(x^2+2)*y(x) = x^3*cos(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \frac {x \left (\left (x +2 c_2 \right ) \sin \left (x \right )+2 \cos \left (x \right ) c_1 \right )}{2} \]
Mathematica. Time used: 0.033 (sec). Leaf size: 49
ode=x^2*D[y[x],{x,2}]-2*x*D[y[x],x]+(x^2+2)*y[x]==x^3*Cos[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \frac {1}{8} e^{-i x} x \left (2 i x+e^{2 i x} (-2 i x+1-4 i c_2)+1+8 c_1\right ) \end{align*}
Sympy
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**3*cos(x) + x**2*Derivative(y(x), (x, 2)) - 2*x*Derivative(y(x), x) + (x**2 + 2)*y(x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
NotImplementedError : The given ODE Derivative(y(x), x) - (x**2*(-x*cos(x) + y(x) + Derivative(y(x), (x, 2)))/2 + y(x))/x cannot be solved by the factorable group method