       Vector formulation of a system of ODEs for NDSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg15551] Vector formulation of a system of ODEs for NDSolve
• From: phillips at crisx.com (Terry Phillips)
• Date: Tue, 26 Jan 1999 13:44:35 -0500 (EST)
• Organization: Los Alamos National Laboratory
• Sender: owner-wri-mathgroup at wolfram.com

```I would like to solve a system of differential equations with NDSolve,
using a vector equation to formulate the equations.  For example,
taking an problem from Chris Barkers excellent tutorial on solving
differential equations with Mathematica
(http://mac205.sjdccd.cc.ca.us/ODE/ODE-h.html (thank you Chris!!)), the
system of differential equations:

(dx/dt)=-x+2y
(dy/dt)=2x-3y
x(0)=1
y(0)=2

is easily solved with NDSolve:

In:=
Clear[x,y,t,sol1x,sol1y]

sol1=NDSolve[{x'[t]==-x[t]+2y[t],x==1,y'[t]==2x[t]-3y[t],y==2},{x[t],y[t]},{t,-1,2}]
Out=
{{x[t]\[Rule]InterpolatingFunction[{{-1.,2.}},"<>"][t],y[t]\[Rule]InterpolatingFunction[{{-1.,2.}},"<>h"][t]}}

If I try to formulate this as a vector equation, where f[]=x and
f[]=y, and use the vector formulation in NDSolve,, I cannot find a
vector formulation of the problem that Mathematica will accept.  E.g.,

Clear[f,t]
Array[f,2]
sol1test=NDSolve[{f[]'[t]==-f[]+2f[],f[]==1,f[]'[t]==2f[]-3f[],f[]==2},{f[][t],f[][t]},{t,-1,2}]
{f,f}

does not work, nor does:

Clear[f,t]
Array[f,2]
sol1test=NDSolve[{f'[t][]==-f[t][]+2f[t][],f[]==1,f'[t][]==2f[t][]-3f[t][],f[]==2},{f[t][],f[t][]},{t,-1,2}]

Is there any way to formulate a system of differential equations in a
vector format for solution by NDSolve?  I am using Mathematica 3.0 with
Windows NT4.0.  Thank you for any help you can give me. Terry Phillips
------  __o phillips at nospam.lanl.gov      -------  _`\<,_     Phone:
505 667-7379 US Mail: ESA-EPE, MS J576        ---- (*)/ (*)    FAX: 505
665-1323 Los Alamos National Laboratory                    Los Alamos,
NM 87545

```

• Prev by Date: Re: ListDensityPlot gives PostScript error
• Next by Date: Re: combining surface graphics
• Previous by thread: Comparison of Mathematica on Various Computers
• Next by thread: How to construct all possible orderings