Cannot get specific value from NDSolve (multiple functions)

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

Clear[Solution,P1,P2,P3,Pbar1,Pbar2,Pbar3,tmax];
tmax=2;
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],

P1==0,P2==0,P3==1,Pbar1==0,Pbar2==0,Pbar3==1},

{P1[t],P2[t],P3[t],Pbar1[t],Pbar2[t],Pbar3[t]},{t,0,tmax}]


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:

P3/.Solution


I get

{P3}


when I expect to get

{1}


or something like that.

Does anyone know what's wrong?

• 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. – Szabolcs Feb 10 '14 at 17:24
• FWIW, I like to set up my equations with exact coefficients. It makes certain things easier, such as adjusting the working precision. – Michael E2 Dec 26 '14 at 16:32

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, P2 == 0, P3 == 1,
Pbar1 == 0, Pbar2 == 0, Pbar3 == 1}, {P1, P2, P3, Pbar1,
Pbar2, Pbar3}, {t, 0, tmax}][]
Plot[{P1[t], P2[t], P3[t], Pbar1[t], Pbar2[t], Pbar3[t]} /. Solution, {t, 0, tmax}] And here it is using tmax = 300:

Plot[{P1[t], P2[t], P3[t], Pbar1[t], Pbar2[t], Pbar3[t]} /. Solution, {t, 0, tmax}] Is this the behavior you are looking for?

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