29.6.27 problem 33

Internal problem ID [7312]
Book : Mathematical Methods in the Physical Sciences. third edition. Mary L. Boas. John Wiley. 2006
Section : Chapter 8, Ordinary differential equations. Section 6. SECOND-ORDER LINEAR EQUATIONSWITH CONSTANT COEFFICIENTS AND RIGHT-HAND SIDE NOT ZERO. page 422
Problem number : 33
Date solved : Tuesday, September 30, 2025 at 04:28:05 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+y&=x^{3}-1+2 \cos \left (x \right )+\left (2-4 x \right ) {\mathrm e}^{x} \end{align*}
Maple. Time used: 0.003 (sec). Leaf size: 32
ode:=diff(diff(y(x),x),x)+y(x) = x^3-1+2*cos(x)+(2-4*x)*exp(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \left (c_1 +1\right ) \cos \left (x \right )+\left (-2 x +3\right ) {\mathrm e}^{x}+\left (c_2 +x \right ) \sin \left (x \right )+x^{3}-6 x -1 \]
Mathematica. Time used: 0.214 (sec). Leaf size: 89
ode=D[y[x],{x,2}]+y[x]==x^3-1+2*Cos[x]+(2-4*x)*Exp[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \cos (x) \int _1^x-\left (\left (K[1]^3+2 \cos (K[1])+e^{K[1]} (2-4 K[1])-1\right ) \sin (K[1])\right )dK[1]+\sin (x) \int _1^x\cos (K[2]) \left (K[2]^3+2 \cos (K[2])+e^{K[2]} (2-4 K[2])-1\right )dK[2]+c_1 \cos (x)+c_2 \sin (x) \end{align*}
Sympy. Time used: 0.071 (sec). Leaf size: 34
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**3 - (2 - 4*x)*exp(x) + y(x) - 2*cos(x) + Derivative(y(x), (x, 2)) + 1,0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{2} \cos {\left (x \right )} + x^{3} - 2 x e^{x} - 6 x + \left (C_{1} + x\right ) \sin {\left (x \right )} + 3 e^{x} - 1 \]