1

I have a pretty little NDSolve function that I've finally decked out with manipulatable (by sliders) coefficients, which changes the graph in real time. However, I used dummy equations in making sure I could set up the system I want, which I have as you can see by simply copy-pasting:

Manipulate[
 Plot[
  Evaluate[{a[t], b[t], c[t]} /.
    NDSolve[
     {a'[t] == -k1f*a[t] + k1r*b[t],
      b'[t] == k1f*a[t] - k1r*b[t] - k2f*b[t],
      c'[t] == k2f*b[t],
      a[0] == a0,
      b[0] == 0.0,
      c[0] == 0.0},
     {a, b, c}, {t, 0, 1500}, MaxSteps -> 1000, AccuracyGoal -> 10]],
  {t, 0, 1500}, PlotRange -> {{0, 1500}, {0, 0.11}}, 
  AxesLabel -> {"Time (Seconds)", "Concentration"},
  PlotStyle -> {{Red, Thickness[0.008]}, {Green, 
     Thickness[0.008]}, {Blue, Thickness[0.008]}}],
 {{k1f, 0.01, Subscript[k, 1]}, 0, 0.02},
 {{k1r, 0.01, Subscript[k, -1]}, 0, 0.02},
 {{k2f, 0.01, Subscript[k, 2]}, 0, 0.02},
 {{a0, 0.1, Subscript[a, init]}, 0, .2}]

All I want is to rename my equations (a'[t], b'[t], c'[t]) in the first argument of NDSolve to a nickname, eqns, to simplify looking at them when they aren't the dummy 3 equations but are my real 150 equations, instead.

But eqns = {a'[t] == -k1f*a[t] + k1r*b[t], ... as is done in the first argument of NDSolve above, followed by `NDSolve[z,{a, b, c}, etc.] returns a ridiculous number of errors.

Where am I going wrong?

Answered! For those of you still confused after reading the original question's answer (linked above), please see the comments for a short answer as to how to address my scenario specifically.

Ghersic
  • 1,147
  • 7
  • 21
  • You need to name your equations eqs[k1f, k1r, a0, k2f] so that you are affecting the variables within the equations themselves when you use Manipulate: eqs[k1f_, k1r_, a0_, k2f_] = {a'[t] == -k1f*a[t] + k1r*b[t], b'[t] == k1f*a[t] - k1r*b[t] - k2f*b[t], c'[t] == k2f*b[t], a[0] == a0, b[0] == 0.0, c[0] == 0.0}; – Jonathan Shock May 23 '13 at 01:02
  • Related or possible duplicate: http://mathematica.stackexchange.com/q/10604/121 – Mr.Wizard May 23 '13 at 01:47
  • @Shock Thank you both, apologies for the duplicate entry. If I do find a solution based on the article and this one isn't closed, I'll update my progress. – Ghersic May 23 '13 at 04:46
  • @Mr.Wizard ^ (See Above) Wouldn't let me post two notifications simultaneously. – Ghersic May 23 '13 at 04:47
  • My confusion in relating his question to mine is in defining (what he called bigA[t_]) and what I suppose I would call eqns[a'_, b'_, c'_, a_. b_, c_]... I will sit on this and update as I progress. – Ghersic May 23 '13 at 05:50
  • Ah, @Stock I see exactly what you mean now, which clears up my previous comment above. I'm glad I re-read your comment after looking at Mr. Wizard's link. It is eqns as a function of those parameters being changed with manipulate that I want to place within NDSolve, not eqns as a function of the dependent variables within NDSolve. Thank you both. I see the relevance of what you linked as well, Mr. Wizard. – Ghersic May 23 '13 at 05:53
  • @Mr.Wizard What is the best way to go about marking a question as answered if the answer can be found in one or more comments? Thanks again, fellows. – Ghersic May 23 '13 at 05:56
  • 2
    If the question is answered in another question it should be closed as "already answered here..." (duplicate). If it is answered in comments that are not a duplicate of an earlier answer then an answer should be posted. You can either encourage someone (@Jonathan) to post an answer, or you can post it yourself and Accept your own answer. Either is appreciated and better than having a question appear unresolved when it is really not. In this case three people feel this is a duplicate and I tend to agree with them, unless you have strong feeling to the contrary. – Mr.Wizard May 23 '13 at 11:06
  • @Mr.Wizard I agree that it is a duplicate. My initial confusion was, I think, more due to my own novice than any lack of similarity between this question and the link you posted. Thank you both. – Ghersic May 23 '13 at 21:50

0 Answers0