15.14.17 problem 17

Internal problem ID [3189]
Book : Differential Equations by Alfred L. Nelson, Karl W. Folley, Max Coral. 3rd ed. DC heath. Boston. 1964
Section : Exercise 23, page 106
Problem number : 17
Date solved : Sunday, March 30, 2025 at 01:20:49 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+2 y&=x^{2} {\mathrm e}^{-x} \end{align*}

Maple. Time used: 0.004 (sec). Leaf size: 35
ode:=diff(diff(y(x),x),x)+2*y(x) = x^2*exp(-x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \cos \left (\sqrt {2}\, x \right ) c_1 +\sin \left (\sqrt {2}\, x \right ) c_2 +\frac {\left (\frac {2}{9}+x^{2}+\frac {4}{3} x \right ) {\mathrm e}^{-x}}{3} \]
Mathematica. Time used: 0.024 (sec). Leaf size: 47
ode=D[y[x],{x,2}]+2*y[x]==x^2*Exp[-x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{27} e^{-x} \left (9 x^2+12 x+2\right )+c_1 \cos \left (\sqrt {2} x\right )+c_2 \sin \left (\sqrt {2} x\right ) \]
Sympy. Time used: 0.124 (sec). Leaf size: 46
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**2*exp(-x) + 2*y(x) + Derivative(y(x), (x, 2)),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^{2} e^{- x}}{3} + \frac {4 x e^{- x}}{9} + \frac {2 e^{- x}}{27} \]