MathGroup Archive 2008

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

Search the Archive

Vector valued differential equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87998] Vector valued differential equations
  • From: dh <dh at metrohm.ch>
  • Date: Mon, 21 Apr 2008 14:37:37 -0400 (EDT)


Hello,

I lately asked if it is possible to write differential equations of 

vector valued functions without having to explicitely write all 

components. For the following cases it can be done very easily:

Assume we are looking for a vector valued function 

y[t]={y1[t],y2[t]..,ym[t]}.

To begin with, assume further that we have a first order differential 

equations that can  be written explicitly as:

y1'= f1[t,y]; y2'=f2[t,y],..,fm[t,y]

then with

F[t_,y_?VectorQ]:={f1[t,y],f12[t,y],..}

where VectorQ ensure that the function is not called with symbolic 

arguments. With initial conditions y0={y10,y20,..} we can write the DE like:

eq={y'[t]==F[t,y[t]], y[0]==y0};

NDSolve[eq,y[t],{t,0,tend}]



If we have a n-th order DE, we may use the same trick. We now have:

y1'= f11[t,y,y'..]; y2'=f21[..];..;ym'=fm1[..];

y1''=f12[..];..;ym''=fm2[..]; ....

y1((n-1) derivative))= f1(n-1)[..];..;ym((n-1)derivative)=fm(n-1)[..]

instead of y we have:

f={y1,y2,..,y1',y2',..,(n-1)derivative of y1,..}

with F and initial conditions f0:

F[t_,f_?VectorQ]:={f11,f21,..,fm1,f21,f22,..,fm2,..,f1(n-1)}

f0={y1[0],..,ym[0],y1'[0],..,(n-1)drivative of fm[0]}

the DE can be written:

eq={f'[t]==F[t,f[t]], f[0]==f0};

NDSolve[eq,y[t],{t,0,tend}]



Here is a simple example, the 2-dim Kepler problem:

f0={10,0,0,0.18};(*{x,y,vx,vy}*)

tend=80;

F[p_?VectorQ]:=({p[[3]],p[[4]],-p[[1]]/(p[[1]]^2+p[[2]]^2)^(3/2),-p[[2]]/(p[[1]]^2+p[[2]]^2)^(3/2)});

eq={f'[t]==F[f[t]],f[0]==f0};

sol4=f[t]/.NDSolve[eq,f[t],{t,0,tend}][[1]];

ParametricPlot[{sol4[[1]],sol4[[2]]},{t,0,tend},Mesh->True]

Daniel




  • Prev by Date: Re: Re: Timing
  • Next by Date: Re: problem accessing notebooks
  • Previous by thread: Re: need help with Plot
  • Next by thread: Dynamic: feature?