Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

OK guys, here's the thing, Mathematica does not return a solution for this system of differential equations:

DSolve[{p11'[t] == 2*p12[t] - (1/r)*p12[t]^2, 
p12'[t] == 
p22[t] - (w^2)*p11[t] - 2*z*w*p12[t] - (1/r)*p12[t]*p22[t], 
p22'[t] == -2*(w^2)*p12[t] - 
4*z*w*p22[t] - (1/r)*p22[t]^2 + (w^4)*q, p11[0] == 0, p12[0] == 0,
p22[0] == 0}, {p11[t], p12[t], p22[t]}, t]

Where z,w,r,q are parameters. Can anyone please try it on your system and tell me if you have the same problem?

I also tried with the NDSolve function

NDSolve[{p11'[t] == 2*p12[t] - (1/r)*p12[t]^2, 
p12'[t] == 
p22[t] - (w^2)*p11[t] - 2*z*w*p12[t] - (1/r)*p12[t]*p22[t], 
p22'[t] == -2*(w^2)*p12[t] - 
4*z*w*p22[t] - (1/r)*p22[t]^2 + (w^4)*q, p11[0] == 0, p12[0] == 0,
p22[0] == 0}, {p11[t], p12[t], p22[t]}, {t, 0, 10}]

but I get the error message:NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.

I greatly appreciate your help

(I use mathematica 8.0 and of course VariationalMethods is turned on)

share|improve this question
    
"Mathematica does not return a solution for this system of differential equations" - this merely means that Mathematica doesn't know a lot of things, and your system of DEs is among those. –  J. M. Jun 20 '12 at 7:46
    
Why is it so obvious to turn on VariationalMethods (I guess you mean that you loaded the VariationalMethods package using << or Get)? NSolve or NDSolve don't need that. –  Sjoerd C. de Vries Jun 20 '12 at 12:25
add comment

2 Answers

up vote 6 down vote accepted

When using NDSolve all the parameters must have a numeric value.

solution[t_] = 
  With[{q = 1, r = 1, w = 1, z = 1}, 
   NDSolve[{p11'[t] == 2*p12[t] - (1/r)*p12[t]^2,
            p12'[t] == p22[t] - (w^2)*p11[t] - 2*z*w*p12[t] - (1/r)*p12[t] p22[t],
            p22'[t] == -2 (w^2)*p12[t] - 4*z*w*p22[t] - (1/r)*p22[t]^2 + (w^4)*q,
            p11[0] == 0,  p12[0] == 0, p22[0] == 0},
           {p11[t], p12[t], p22[t]}, {t, 0, 10}]][[1, All, 2]]

Plot[solution[t], {t, 0, 10}]

enter image description here

share|improve this answer
    
oh wow i didn't know that, i thought it could solve using these quantities as parameters. And the command [1, All, 2] in the end, what's it about? –  Lazaros M. Jun 20 '12 at 7:55
    
@LazarosM. It's to get the functions from the solution to your system of equations, given in terms of rules. If you execute the With[...] block alone you will see. –  b.gatessucks Jun 20 '12 at 7:58
    
@LazarosM. Actually its [[1, All, 2]]. It's short for Part and it's about getting the solutions in a list for plotting –  Ajasja Jun 20 '12 at 7:59
    
Guys thank you all very much, you have been extremely helpful! and thenks for the quick immediate responses –  Lazaros M. Jun 20 '12 at 8:04
add comment

Just for fun, here is a version with Manipulate. So the values of parameters can be dynamically changed:

Manipulate[
 solution[t_] = 
  NDSolve[{p11'[t] == 2*p12[t] - (1/r)*p12[t]^2, 
     p12'[t] == 
      p22[t] - (w^2)*p11[t] - 2*z*w*p12[t] - (1/r)*p12[t] p22[t], 
     p22'[t] == -2 (w^2)*p12[t] - 
       4*z*w*p22[t] - (1/r)*p22[t]^2 + (w^4)*q, p11[0] == 0, 
     p12[0] == 0, p22[0] == 0}, {p11[t], p12[t], p22[t]}, {t, 0, 
     10}][[1, All, 2]];

 Plot[solution[t], {t, 0, 10}]
 , {{q, 1}, -10, 10, Appearance -> "Labeled"}
 , {{r, 1}, -10, 10, Appearance -> "Labeled"}
 , {{w, 1}, -10, 10, Appearance -> "Labeled"}
 , {{z, 1}, -10, 10, Appearance -> "Labeled"},
 TrackedSymbols :> {q, r, w, z}]

Manipulate

share|improve this answer
add comment

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.