MathGroup Archive 2008

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

Search the Archive

Re: NDSolve with arrays

  • To: mathgroup at
  • Subject: [mg89232] Re: NDSolve with arrays
  • From: dh <dh at>
  • Date: Sun, 1 Jun 2008 03:33:47 -0400 (EDT)
  • References: <g1m8ev$ia$>

Hi Svend,

Name the 10 functions you are looking for: f1..f10. Note that all 10 

functions have the same derivatives. Further, from t=m to t=m+1, the 

derivative is fm[x]. We therefore solve the equations from t=1 to t=2 

using f1 for the derivatives. Then from t=2 to t=3 using f2 etc. 

Therefore we have an outermost Do loop that iterates over starting times.

To solve, we first setup a list with function names:funs = 

Table[Symbol["f" <> ToString[j]], {j, 1, n}]

Then we define the equations, remembering that in step m the derivatives 

are given by fm:



finally we solve ad append the soulution to the solution list: tes:

AppendTo[tes, NDSolve[eqs, funs, {x, x0, x0 + 1}][[1]]];

Finally we need to assemple the different pieces of the 10 functions 

into Piecewise functions:



Here is the whole code:












hope this helps, Daniel

svend wrote:

> hi all,

> i want to solve a PDE by discretizing in one variable in an array and solve. the equations are of the following type:

> n = 10;

> x0 = 1;

> x1 = 10;


> play[x_] := IntegerPart[x]


> eq1 := {D[f[j][x], x] == f[play[x]][x], f[j][x0] == j^2}


> eqs = Flatten[Table[eq1, {j, 1, n}]]

> fun = Flatten[Table[f[j], {j, 1, n}]];

> tes = NDSolve[eqs, fun, {x, x0, x1}][[1]];


> my problem is that the variable x, in which the equation is differential, also appears on the rhs in the "index" of my array. mathematica does not evaluate "play[x]" during NDSolve and just tells me that the rhs is not numerical. I tried "_NumericQ" and similar things but nothing seems. I would be very happy if someone could tell me how to resolve this.


> thanks

> svend



Daniel Huber

Metrohm Ltd.

Oberdorfstr. 68

CH-9100 Herisau

Tel. +41 71 353 8585, Fax +41 71 353 8907

E-Mail:<mailto:dh at>


  • Prev by Date: Re: ContourPlot3D appearance
  • Next by Date: Re: Default location for Exported files?
  • Previous by thread: Re: NDSolve with arrays
  • Next by thread: Re: NDSolve with arrays