Re: multiple subscripted variables in NDSolve; dsfun
- To: mathgroup at smc.vnet.net
- Subject: [mg21995] Re: [mg21979] multiple subscripted variables in NDSolve; dsfun
- From: Hartmut Wolf <hwolf at debis.com>
- Date: Thu, 10 Feb 2000 02:25:37 -0500 (EST)
- Organization: debis Systemhaus
- References: <200002071802.NAA08387@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
stephen e. schwartz schrieb: > > I am attempting to use NDSolve (Mathematica 4.0.1.0, 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 In[2]:= 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 In[3]:= 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 variables. So In[4]:= 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
- References:
- multiple subscripted variables in NDSolve; dsfun
- From: "stephen e. schwartz" <ses@bnl.gov>
- multiple subscripted variables in NDSolve; dsfun