MathGroup Archive 1998

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

Search the Archive

Re: Numerical Solution to a System of Differential Equations...


  • To: mathgroup@smc.vnet.net
  • Subject: [mg12233] Re: Numerical Solution to a System of Differential Equations...
  • From: Paul Abbott <paul@physics.uwa.edu.au>
  • Date: Tue, 5 May 1998 03:29:30 -0400
  • Organization: University of Western Australia
  • References: <6ibvba$ev@smc.vnet.net>

Ragavan wrote:

> Now, I try to solve using NDSolve:
> 
> In[4]:= NDSolve[ {MapThread[Equal,{y', M.y}],
> MapThread[Equal,{y0,Init}]},
>         y, {t,0,10}]

You could just write

	NDSolve[{Thread[y' == M . y], Thread[y0 == Init]}, y, {t, 0, 10}]
 
> and obtain an output which looks like this:
> 
> Out[4]={y1[t]\[Rule]InterpolatingFunction[{{0.`,10.`}},"<>"][t],
>         y2[t]\[Rule]InterpolatingFunction[{{0.`,10.`}},"<>"][t],
>         y3[t]\[Rule]InterpolatingFunction[{{0.`,10.`}},"<>"][t]}}
> 
> (y1, y2, y3 are elements in the y vector.)


	y = {y1[t],y2[t],y3[t],y4[t]}

for otherwise NDSolve would return

	{y1\[Rule]InterpolatingFunction[{{0.`,10.`}},"<>"], ...

> But when I try to look at the result for a given value of the dependent
> variable t (say 5):
> 
> In[5]:= y3[5] /. %
> 
> all I get is
> 
> Out[5]= y3[5]

This is because the replacement rule is for y1[t] not for y1.  Here is
one way to get what you want:

  y = {y1, y2, y3, y4};
  
  NDSolve[{Thread[D[Through[y[t]], t] == M . Through[y[t]]], 
	Thread[Through[y[0]] == Init]}, y, {t, 0, 10}]

  {{y1 -> InterpolatingFunction[], 
    y2 -> InterpolatingFunction[], 
    y3 -> InterpolatingFunction[], 
    y4 -> InterpolatingFunction[]}}

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul@physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________



  • Prev by Date: Re: Want a smooth function from Arg[ ]
  • Next by Date: Re: pallette subscript confusion
  • Prev by thread: Re: Numerical Solution to a System of Differential Equations...
  • Next by thread: Mathematica 3.0 preferences-file