0
$\begingroup$

I'm trying to run the code:

sol = DSolve[{Derivative[1][Subscript[x, 1]][
     t] == -(1 - Subscript[w, 1]) x1[t] - 
     Subscript[σ, 12] Subscript[x, 1][t], 
   Derivative[1][p][t] == -(1 - Subscript[w, 2]) p[t] + 
     Subscript[σ, 12] Subscript[x, 1][t], 
   Subscript[x, 1][0] == 1000, p[0] == 0}, {Subscript[x, 1][t], p[t]},
   t]

which is the same as:

sol = DSolve[{Derivative[1][Subscript[x, 1]][
     t] == -(1 - w1)*Subscript[x, 1][t] - s12*Subscript[x, 1][t], 
   Derivative[1][p][t] == -(1 - w2) p[t] + s12 Subscript[x, 1][t], 
   Subscript[x, 1][0] == 1000, p[0] == 0}, {Subscript[x, 1][t], p[t]},
   t]

The only difference is in the name of the variables, the second one gives a solution but not the first.

Also, in the following code:

    Manipulate[
 sol = DSolve[{Derivative[1][Subscript[x, 1]][
      t] == -(1 - Subscript[w, 1]) x1[t] - 
      Subscript[σ, 12] Subscript[x, 1][t], 
    Derivative[1][p][t] == -(1 - Subscript[w, 2]) p[t] + 
      Subscript[σ, 12] Subscript[x, 1][t], 
    Subscript[x, 1][0] == 1000, p[0] == 0}, {Subscript[x, 1][t], 
    p[t]}, t];
 Plot[Evaluate[p[t] /. sol[[1, 1]]], {t, 0, 100}, 
  PlotRange -> Automatic], {{Subscript[σ, 12], 0.01, 
   "Mutation 1->2"}, 0.01, 
  1}, {{Subscript[w, 2], 0.5, 
   "Fitness \!\(\*SubscriptBox[\(w\), \(2\)]\)"}, 0, 
  2}, {{Subscript[w, 1], 1, 
   "Fitness \!\(\*SubscriptBox[\(w\), \(1\)]\)"}, 0, 2}]

If I change all instances of p[t] to Subscript[x,2] it stops working.

Any idea on what's going on?

$\endgroup$
2
  • 2
    $\begingroup$ In your first expression, you forgot to change one of the x1s. If you change the x1[t] to a Subscript[x, 1][t], then they yield the same results. The same thing in your Manipulate. $\endgroup$
    – march
    Commented Jul 7, 2016 at 18:02
  • $\begingroup$ You're right, thank you very much. $\endgroup$
    – phytab
    Commented Jul 7, 2016 at 21:18

1 Answer 1

1
$\begingroup$

As mentioned by March, you didn't change one of the x1[t] terms to Subscript[x, 1][t]

Your code should read:

sol = DSolve[{Derivative[1][Subscript[x, 1]][t] == 
            -(1 - Subscript[w, 1]) Subscript[x, 1][t] - 
            Subscript[σ, 12] Subscript[x, 1][t], 
   Derivative[1][p][t] == 
            -(1 - Subscript[w, 2]) p[t] + Subscript[σ, 12] Subscript[x, 1][t], 
   Subscript[x, 1][0] == 1000, p[0] == 0}, {Subscript[x, 1][t], p[t]}, t]


Manipulate[
 sol = DSolve[{Derivative[1][Subscript[x, 1]][
      t] == -(1 - Subscript[w, 1]) Subscript[x, 1][t] - 
      Subscript[σ, 12] Subscript[x, 1][t], 
    Derivative[1][p][t] == -(1 - Subscript[w, 2]) p[t] + 
      Subscript[σ, 12] Subscript[x, 1][t], 
    Subscript[x, 1][0] == 1000, p[0] == 0}, {Subscript[x, 1][t], p[t]}, t];
 Plot[Evaluate[p[t] /. sol[[1, 1]]], {t, 0, 100}, 
  PlotRange -> Automatic], {{Subscript[σ, 12], 0.01, 
   "Mutation 1->2"}, 0.01, 1}, {{Subscript[w, 2], 0.5, 
   "Fitness \!\(\*SubscriptBox[\(w\), \(2\)]\)"}, 0, 
  2}, {{Subscript[w, 1], 1,"Fitness \!\(\*SubscriptBox[\(w\), \(1\)]\)"}, 0, 2}]
$\endgroup$

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