\[ \boxed { \left ( {x}^{2}+1 \right ) {\frac {{\rm d}^{2}}{{\rm d}{x}^{2}}}y \left ( x \right ) +4\,x{\frac {\rm d}{{\rm d}x}}y \left ( x \right ) +2\,y \left ( x \right ) -2\,\cos \left ( x \right ) +2\,x=0} \]
Mathematica: cpu = 0.040505 (sec), leaf count = 48 \[ \left \{\left \{y(x)\to \frac {c_1}{x^2+1}+\frac {c_2 x}{x^2+1}+\frac {-x^3-6 \cos (x)}{3 \left (x^2+1\right )}\right \}\right \} \]
Maple: cpu = 0.016 (sec), leaf count = 41 \[ \left \{ y \left ( x \right ) ={\frac {x{\it \_C1}}{{x}^{2}+1}}+{\frac { {\it \_C2}}{{x}^{2}+1}}-{\frac {{x}^{3}+6\,\cos \left ( x \right ) }{3\, {x}^{2}+3}} \right \} \]