56.27.2 problem Ex 2

Internal problem ID [14221]
Book : An elementary treatise on differential equations by Abraham Cohen. DC heath publishers. 1906
Section : Chapter VII, Linear differential equations with constant coefficients. Article 50. Method of undetermined coefficients. Page 107
Problem number : Ex 2
Date solved : Thursday, October 02, 2025 at 09:26:50 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y-2 y^{\prime }+y^{\prime \prime }&=2 x \,{\mathrm e}^{2 x}-\sin \left (x \right )^{2} \end{align*}
Maple. Time used: 0.003 (sec). Leaf size: 35
ode:=diff(diff(y(x),x),x)-2*diff(y(x),x)+y(x) = 2*x*exp(2*x)-sin(x)^2; 
dsolve(ode,y(x), singsol=all);
 
\[ y = -\frac {1}{2}+2 \left (-2+x \right ) {\mathrm e}^{2 x}-\frac {3 \cos \left (2 x \right )}{50}-\frac {2 \sin \left (2 x \right )}{25}+\left (c_1 x +c_2 \right ) {\mathrm e}^{x} \]
Mathematica. Time used: 0.371 (sec). Leaf size: 53
ode=D[y[x],{x,2}]-2*D[y[x],x]+y[x]==2*x*Exp[2*x]-Sin[x]^2; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to 2 e^{2 x} x-4 e^{2 x}-\frac {2}{25} \sin (2 x)-\frac {3}{50} \cos (2 x)+c_2 e^x x+c_1 e^x-\frac {1}{2} \end{align*}
Sympy. Time used: 0.579 (sec). Leaf size: 42
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-2*x*exp(2*x) + y(x) + sin(x)**2 - 2*Derivative(y(x), x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \left (C_{1} + x \left (C_{2} + 2 e^{x}\right )\right ) e^{x} - 4 e^{2 x} - \frac {2 \sin {\left (2 x \right )}}{25} - \frac {3 \cos {\left (2 x \right )}}{50} - \frac {1}{2} \]