40.11.10 problem 36

Internal problem ID [6744]
Book : Schaums Outline. Theory and problems of Differential Equations, 1st edition. Frank Ayres. McGraw Hill 1952
Section : Chapter 16. Linear equations with constant coefficients (Short methods). Supplemetary problems. Page 107
Problem number : 36
Date solved : Wednesday, March 05, 2025 at 02:42:23 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+2 y&=x^{3}+x^{2}+{\mathrm e}^{-2 x}+\cos \left (3 x \right ) \end{align*}

Maple. Time used: 0.003 (sec). Leaf size: 47
ode:=diff(diff(y(x),x),x)+2*y(x) = x^3+x^2+exp(-2*x)+cos(3*x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (\sqrt {2}\, x \right ) c_2 +\cos \left (\sqrt {2}\, x \right ) c_1 +\frac {x^{3}}{2}+\frac {x^{2}}{2}-\frac {3 x}{2}-\frac {\cos \left (3 x \right )}{7}-\frac {1}{2}+\frac {{\mathrm e}^{-2 x}}{6} \]
Mathematica. Time used: 2.674 (sec). Leaf size: 69
ode=D[y[x],{x,2}]+2*y[x]==x^3+x^2+Exp[-2*x]+Cos[3*x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{42} \left (21 x^3+21 x^2-63 x+7 e^{-2 x}+9 \sin (x) \sin (2 x)-6 \cos ^3(x)+42 c_1 \cos \left (\sqrt {2} x\right )+42 c_2 \sin \left (\sqrt {2} x\right )-21\right ) \]
Sympy. Time used: 0.181 (sec). Leaf size: 56
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**3 - x**2 + 2*y(x) - cos(3*x) + Derivative(y(x), (x, 2)) - exp(-2*x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} \sin {\left (\sqrt {2} x \right )} + C_{2} \cos {\left (\sqrt {2} x \right )} + \frac {x^{3}}{2} + \frac {x^{2}}{2} - \frac {3 x}{2} - \frac {\cos {\left (3 x \right )}}{7} - \frac {1}{2} + \frac {e^{- 2 x}}{6} \]