15.14.16 problem 16

Internal problem ID [3188]
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 : 16
Date solved : Sunday, March 30, 2025 at 01:20:47 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.004 (sec). Leaf size: 26
ode:=diff(diff(y(x),x),x)+4*y(x) = x*exp(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (2 x \right ) c_2 +\cos \left (2 x \right ) c_1 +\frac {\left (5 x -2\right ) {\mathrm e}^{x}}{25} \]
Mathematica. Time used: 0.02 (sec). Leaf size: 32
ode=D[y[x],{x,2}]+4*y[x]==x*Exp[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{25} e^x (5 x-2)+c_1 \cos (2 x)+c_2 \sin (2 x) \]
Sympy. Time used: 0.087 (sec). Leaf size: 29
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x*exp(x) + 4*y(x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} \sin {\left (2 x \right )} + C_{2} \cos {\left (2 x \right )} + \frac {x e^{x}}{5} - \frac {2 e^{x}}{25} \]