Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

Differential Operator method

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

share|improve this question
3  
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
up vote 7 down vote accepted

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]

and the answer is

                                0

QED

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.