4.25.40 \(y''(x)+2 y'(x)+y(x)=x^2+3 e^{2 x}-\cos (x)\)

ODE
\[ y''(x)+2 y'(x)+y(x)=x^2+3 e^{2 x}-\cos (x) \] ODE Classification

[[_2nd_order, _linear, _nonhomogeneous]]

Book solution method
TO DO

Mathematica
cpu = 0.406566 (sec), leaf count = 41

\[\left \{\left \{y(x)\to x^2-4 x+\frac {e^{2 x}}{3}-\frac {\sin (x)}{2}+e^{-x} (c_2 x+c_1)+6\right \}\right \}\]

Maple
cpu = 0.156 (sec), leaf count = 35

\[\left [y \left (x \right ) = {\mathrm e}^{-x} \textit {\_C2} +x \,{\mathrm e}^{-x} \textit {\_C1} +x^{2}-4 x +6-\frac {\sin \left (x \right )}{2}+\frac {{\mathrm e}^{2 x}}{3}\right ]\] Mathematica raw input

DSolve[y[x] + 2*y'[x] + y''[x] == 3*E^(2*x) + x^2 - Cos[x],y[x],x]

Mathematica raw output

{{y[x] -> 6 + E^(2*x)/3 - 4*x + x^2 + (C[1] + x*C[2])/E^x - Sin[x]/2}}

Maple raw input

dsolve(diff(diff(y(x),x),x)+2*diff(y(x),x)+y(x) = x^2-cos(x)+3*exp(2*x), y(x))

Maple raw output

[y(x) = exp(-x)*_C2+x*exp(-x)*_C1+x^2-4*x+6-1/2*sin(x)+1/3*exp(2*x)]