I am trying to solve six connected differential equations. This is my code:

Solution=NDSolve[Rationalize @ {
P1'[t]==-0.01 0.99995 P2[t]-Pbar2[t] P3[t]+Pbar3[t] P2[t],
P2'[t]==-0.01(-0.99995 P1[t]-0.01 P3[t])-Pbar3[t] P1[t]+Pbar1[t] P3[t],
P3'[t]==-0.01 0.01 P2[t]-Pbar1[t] P2[t]+Pbar2[t] P1[t],

Pbar1'[t]==0.01 0.99995 Pbar2[t]+P2[t] Pbar3[t]-P3[t] Pbar2[t],
Pbar2'[t]==-0.01(-0.99995 Pbar1[t]-0.01 Pbar3[t])+P3[t] Pbar1[t]-P1[t] Pbar3[t],
Pbar3'[t]==-0.01 0.01 Pbar2[t]+P1[t] Pbar2[t]-P2[t] Pbar1[t],



No errors and I get the normal output. There is something wrong with it, because the plot doesn't look like I want it to. That is not your problem, but when I try to check the solution by:


I get


when I expect to get


or something like that.

Does anyone know what's wrong?

  • $\begingroup$ The mistake is in the second argument of NDSolve. It should be {P1, P2, P3, Pbar1, Pbar2, Pbar3}, without the [t] arguments. Also, you don't need Rationalize here, but that's not a mistake. Since NDSolve uses numerical methods, it's okay to pass it inexact numbers. $\endgroup$
    – Szabolcs
    Commented Feb 10, 2014 at 17:24
  • $\begingroup$ FWIW, I like to set up my equations with exact coefficients. It makes certain things easier, such as adjusting the working precision. $\endgroup$
    – Michael E2
    Commented Dec 26, 2014 at 16:32

1 Answer 1


In addition to what Szabolcs wrote, you mentioned that the solution doesn't look like what you want it to be. Here is the solution using tmax = 2:

tmax = 2;
s = NDSolve[{P1'[t] == -0.01 0.99995 P2[t] - Pbar2[t] P3[t] + 
      Pbar3[t] P2[t], 
    P2'[t] == -0.01 (-0.99995 P1[t] - 0.01 P3[t]) - Pbar3[t] P1[t] + 
      Pbar1[t] P3[t], 
    P3'[t] == -0.01 0.01 P2[t] - Pbar1[t] P2[t] + Pbar2[t] P1[t], 
    Pbar1'[t] == 
     0.01 0.99995 Pbar2[t] + P2[t] Pbar3[t] - P3[t] Pbar2[t], 
    Pbar2'[t] == -0.01 (-0.99995 Pbar1[t] - 0.01 Pbar3[t]) + 
      P3[t] Pbar1[t] - P1[t] Pbar3[t], 
    Pbar3'[t] == -0.01 0.01 Pbar2[t] + P1[t] Pbar2[t] - 
      P2[t] Pbar1[t], P1[0] == 0, P2[0] == 0, P3[0] == 1, 
    Pbar1[0] == 0, Pbar2[0] == 0, Pbar3[0] == 1}, {P1, P2, P3, Pbar1, 
    Pbar2, Pbar3}, {t, 0, tmax}][[1]]
Plot[{P1[t], P2[t], P3[t], Pbar1[t], Pbar2[t], Pbar3[t]} /. Solution, {t, 0, tmax}]

enter image description here

And here it is using tmax = 300:

Plot[{P1[t], P2[t], P3[t], Pbar1[t], Pbar2[t], Pbar3[t]} /. Solution, {t, 0, tmax}]

enter image description here

Is this the behavior you are looking for?

  • $\begingroup$ Why don't you include the solution from the comment into the answer, to make it complete? $\endgroup$
    – Szabolcs
    Commented Feb 10, 2014 at 19:09
  • $\begingroup$ Added in the correction. $\endgroup$ Commented Feb 10, 2014 at 19:11
  • $\begingroup$ As messy as it may look, yes. That looks more like it! Thank you. $\endgroup$
    – user12291
    Commented Feb 11, 2014 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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