# Why the result by hand is different from the built-in DSolve?

Yesterday, I used the Mathematica to solve a differential equation by the built-in command DSolve:

DSolve[y''[x] + 2 y'[x] + 5 y[x] == x Cos[x], y[x], x]

{{y[x] ->
E^-x C[2] Cos[2 x] + E^-x C[1] Sin[2 x]
+ 1/200 (-25 Cos[x] Cos[2 x] + 25 x Cos[x] Cos[2 x]
- 3 Cos[2 x] Cos[3 x] + 15 x Cos[2 x] Cos[3 x]
- 25 x Cos[2 x] Sin[x] + 25 x Cos[x] Sin[2 x]
+ 4 Cos[3 x] Sin[2 x] + 5 x Cos[3 x] Sin[2 x]
- 25 Sin[x] Sin[2 x] + 25 x Sin[x] Sin[2 x]
- 4 Cos[2 x] Sin[3 x] - 5 x Cos[2 x] Sin[3 x]
- 3 Sin[2 x] Sin[3 x] + 15 x Sin[2 x] Sin[3 x])}}


However,I felt the result is too complex. So I caculate it by hand. My process shown as below.

Characteristic equation: $r^2+2r+5=0 \Rightarrow r_1=-1+2i,r_2=-1-i$

So the Non-homogenerous equation general solution is:$e^{-x}(C_1 \cos(2x)+C_2 \sin(2x))$

I use the Differential Operator method to caculate the non-homogenerous particular solution:

So my question is why the two results are different? Can someone tell me the reason?

-
If you simplify M answer, then it becomes: Simplify[%]; y[x] -> 1/50 E^-x (50 C[2] Cos[2 x] + E^x (-1 + 5 x) Sin[x] +Cos[x] (E^x (-7 + 10 x) + 100 C[1] Sin[x])) – Nasser Nov 17 '13 at 3:35

They are the same answer, as verified below. You can use the Simplify command to simplify things if needed:

mma = y[x] /. First@DSolve[y''[x] + 2 y'[x] + 5 y[x] == x Cos[x], y[x], x];
handH = E^(-x)*(C[2] Cos[2 x] + C[1] Sin[2 x]);
handP = (1/5 x - 7/50) Cos[x] + (1/10 x - 1/50) Sin[x];
hand = handH + handP;
Simplify[mma - hand]


                                0