MathGroup Archive 1999

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

Search the Archive

Re: Vector-valued DE's

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16538] Re: Vector-valued DE's
  • From: Dirk Kraaijpoel <kraai at geo.uu.nl>
  • Date: Tue, 16 Mar 1999 04:00:15 -0500
  • Organization: Universiteit Utrecht
  • References: <7c5bih$7ro@smc.vnet.net> <7cd35h$nna@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Kevin, thank you for your help.
Unfortunately it does not help me too much. 
By simplifying the problem using an example, you have drawn
the sting out of it.
What you basically propose is producing the tables that i wanted
to avoid.
The problem is that my righthandside function (rhs[z[t]]) is not
simply a function of t, but a function of all elements in z.
Moreover, it is a computationally expensive function, which
I want to evaluate only once for each iteration, and which
I do not want to do symbolically (even if i could).

Let's recall my original problem:
I would like to do:

NDSolve[ { z'[t]==rhs[z[t]] , z[0]=incon }, z , {t,0,1}]

where z,rhs and incon are vector valued.
They may contain in the order of 100 elements.

Now, for the initial conditions, producing a Table like you
proposed would be no problem.
I could make a table:

   incnds=Table[z[i][t]==incon[[i]],{i,1,n}] 

or something.
For the differential equations itself, however it is not
that easy.
Of course I could do the same thing: 

   vars = Table[ z[i][t], {i,1,n} ]
   deqns = Table[ z[i][t] == rhs[vars][[i]], {i,1,n}]

and then

   NDSolve[Flatten[{deqns,incnds}],vars,{t,0,1}]

This would mean however, that rhs would be re-evaluated
for every element of z, after which the right element (rhs[vars][[i]])
is chosen. That means that rhs is evaluated n times as often as
necessary,
which is unacceptable for me.
It would be solved if one could, for every 't', calculate the rhs-array,
and then produce the table like above. This does not seem to comply
however,
to the d-equation solving paradigm using logical equations, as chosen
by Mathematica.

Although it seems a trivial problem I have spend a lot
of time on it, and haven't found the answer.
It is a pity that the internals of (N)DSolve are "internal"
indeed, because it probably would not be hard to solve on a 
slightly lower level. 
NDSolve should be able to work with list-equations easily.
I find it hard to believe that a problem which is
trivial in MathCad (a much less sophisticated program)
is so hard in Mathematica. I suspect that an elegant
solution must exist, but I haven't found it..

Somebody able to help me?
Dirk

"Kevin J. McCann" wrote:
> 
> I think the following is what you are after:
> 
> Thread[{a,b,c}=={d,e,f}]
> 
> {a==d,b==e,c==f}
> 
> To use in DE's:
> 
> Your vector function:
> 
> z[t_]={a[t],b[t],c[t]}
> 
> and
> 
> rhs[t_]={d[t],e[t],f[t]}
> 
> Now
> 
> z''[t]==rhs[t]
> 
> doesn't quite work, but
> 
> Thread[z''[t]==rhs[t]]
> 
> {a''[t]==d[t],b''[t]==e[t],c''[t]==f[t]}
> 
> Similarly for the IC's, then just use Flatten to get a single list with DE +
> IC.
> 
> Hope this helps,
> 
> Kevin
>


  • Prev by Date: Re: Sqrt[Sin^2(x)]=Sin(x)....????
  • Next by Date: Real variables (i.e. non-complex)
  • Previous by thread: Re: Vector-valued DE's
  • Next by thread: Re: Re: Vector-valued DE's