MathGroup Archive 2000

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

Search the Archive

Re: Q: NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21576] Re: Q: NDSolve
  • From: Bojan Bistrovic <bojanb at physics.odu.edu>
  • Date: Sat, 15 Jan 2000 02:04:19 -0500 (EST)
  • Organization: Old Dominion Universityaruba
  • References: <85mmgb$268@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Christoph Handel wrote:
> 
>    howdy,
> 
> is there a nice way to solve an equation like this:
> 
> x'[t] == aMatrix[t] . x[t]
> 
> where x ist a Vector.
> 
> I tried something like this:
> 
> NDSolve[{x'[t]== aMatrix[t] . x[t], x[0]=={1,2,3...}},x,{t,0,42}]
> 
> Greetings
>         Christoph
> --
> the adress is valid
> for faster reply use handel at the same host

This might not be "a nice" way, but it works:

In[1]:=
MyEqual[arg1_List==arg2_List]:=Map[Part[Thread[#1],1]&,Thread[arg1==arg2]]

In[2]:= MyEqual[arg1_==arg2_]:=
  Map[Part[Thread[#1],1]&,Thread[MyThread[arg1]==MyThread[arg2]]]


In[3]:= SetAttributes[MyApplyFunction,Listable]
In[4]:= MyApplyFunction[f_,t_]:=f[t]/;MyfunctionTest[f]
In[5]:= MyApplyFunction[f_,t_]:=f/;Not[MyfunctionTest[f]]
In[6]:= MyThread[xx_/;Head[Head[xx]]===List]:=
  xx//.aa_List[t_]:>Map[MyApplyFunction[#1,t]&,aa]

In[7]:= MyThread[xx_[t_]/;Head[Head[xx]]===Derivative]:=
  MyThread[Map[Thread,Thread[xx]][t]]

In[8]:= MyThread[xx_==yy_]:=MyThread[xx]==MyThread[yy]
In[9]:= MyThread[xx_ .yy_]:=MyThread[xx].MyThread[yy]

In[10]:= x={{f1},{f2}};
In[11]:= A={{2, t},{t+3,5}};

In[12]:=
NDSolve[Join[MyEqual[x'[t]==A[t].x[t]],MyEqual[MyThread[x[0]]=={1,2}]],
  Map[Part[#1,1]&,x],{t,0,10}]

Out[12]:={{f1 -> InterpolatingFunction[{{0.,10.}},"<>"],
    f2 -> InterpolatingFunction[{{0.,10.}},"<>"]}}

You'll probably want to modify MyfunctionTest to fit your needs.

Bye, Bojan

-- 
-------------------------------------------------------------
Bojan Bistrovic,                       bojanb at physics.odu.edu  
Old Dominion University, Physics Department,      Norfolk, VA
-------------------------------------------------------------


  • Prev by Date: Re: ReadList of Complex Numbers
  • Next by Date: Re: Alternative cf format.
  • Previous by thread: Q: NDSolve
  • Next by thread: Re: Q: NDSolve