MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: multiple subscripted variables in NDSolve; dsfun

  • To: mathgroup at
  • Subject: [mg21995] Re: [mg21979] multiple subscripted variables in NDSolve; dsfun
  • From: Hartmut Wolf <hwolf at>
  • Date: Thu, 10 Feb 2000 02:25:37 -0500 (EST)
  • Organization: debis Systemhaus
  • References: <>
  • Sender: owner-wri-mathgroup at

stephen e. schwartz schrieb:

> I am attempting to use NDSolve (Mathematica, mac) to solve a set of coupled
> ODEs in the time variable t.  Initially I had a set of variables a[i][t],
> which solve just fine.  The index [i] ranges {1, nc}
> Then I wanted to add another set of variables mn[i][t].  Attempts to solve
> the set (it is still a set of ODEs) brings the response:
> NDSolve::dsfun: "{a[1][t], mn[1][t]} cannot be used as a function"
> I had defined the argument of NDSolve as a table,
> NDSolve[{eq, ic}, Table[{a[i][t], mn[i][t]}, {i, nc}] where eq, ic are
> tables of equations and initial conditions, resp.
> If I "fool" Mathematica by renaming the variable mn[i] as a[i + nc] and suitably
> modify my equations and initial conditions, and the range if the index, the
> set solves just fine, although I am very unhappy about the notation in that
> a and mn represent very different variables.
> So, am I correct in inferring that the compact notation for a set of
> coupled indexed equations (Mathematica book, 4th ed, sec 3.9.7, page 926) works
> only for a single variable name?
> Is there a more elegant fix?

Dear Stephen,

if you rework the example in sec. 3.5.10 of The Mathematica Book

In[1]:= DSolve[{y[x] == -z'[x], z[x] == -y'[x]}, {y, z}, x]

to your manner of denoting the variables

DSolve[{a[1][t] == -mn[1]'[t], mn[1][t] == -a[1]'[t]}, {a[1], mn[1]}, t]

you'll see it isn't that. Instead you introduced Table

DSolve[{a[1][t] == -mn[1]'[t], mn[1][t] == -a[1]'[t]}, 
  Table[{a[i], mn[i]}, {i, 1}], t]

and it stops working  -- because now you no longer have a flat list of

DSolve[{a[1][t] == -mn[1]'[t], mn[1][t] == -a[1]'[t]}, 
  Flatten[Table[{a[i], mn[i]}, {i, 1}]], t]

Kind regards, Hartmut

  • Prev by Date: Orientation of characters in FrameLabel
  • Next by Date: Re: numeric inverse laplace transform of numeric data
  • Previous by thread: multiple subscripted variables in NDSolve; dsfun
  • Next by thread: Re: multiple subscripted variables in NDSolve; dsfun