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.0321189 (sec), leaf count = 41

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

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

\[ \left \{ y \left ( x \right ) ={{\rm e}^{-x}}{\it \_C2}+x{{\rm e}^{-x}}{\it \_C1}+{x}^{2}-4\,x+6-{\frac {\sin \left ( x \right ) }{2}}+{\frac {{{\rm 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),'implicit')

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)