4.31.46 \(\left (x^2+1\right ) y''(x)+4 x y'(x)+2 y(x)=2 (\cos (x)-x)\)

ODE
\[ \left (x^2+1\right ) y''(x)+4 x y'(x)+2 y(x)=2 (\cos (x)-x) \] ODE Classification

[[_2nd_order, _exact, _linear, _nonhomogeneous]]

Book solution method
TO DO

Mathematica
cpu = 0.185744 (sec), leaf count = 33

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

Maple
cpu = 0.133 (sec), leaf count = 41

\[\left [y \left (x \right ) = \frac {\textit {\_C1} x}{x^{2}+1}+\frac {\textit {\_C2}}{x^{2}+1}-\frac {x^{3}+6 \cos \left (x \right )}{3 \left (x^{2}+1\right )}\right ]\] Mathematica raw input

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

Mathematica raw output

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

Maple raw input

dsolve((x^2+1)*diff(diff(y(x),x),x)+4*x*diff(y(x),x)+2*y(x) = 2*cos(x)-2*x, y(x))

Maple raw output

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