help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can i do ODE2 problems with lsode ?


From: Ian Searle
Subject: Re: can i do ODE2 problems with lsode ?
Date: Thu, 30 Nov 1995 13:05:27 -0800

> Hi gang;
> 
>       I have been trying to do some neural-net and dynamical systems 
> stuff that i have been assigned as homework.
> 
>       This means i need to solve ODE's and sytems of ODE's. Octave has 
> dassl and lsode for this purpose. I am not sure how i need to pre process 
> my equations to get them into a form that lsode or dassl would be willing 
> to digest.
> 
>       The example in the manual for lsode is pretty good, the entry for 
> dassl does not have an example, but the description seems pretty complete.
> 
>       Here is the function that i want to try and solve first, since i 
> think it is a "simple" example of what comes in the real stuff.
> 
>       d^2 x                       dx
>       ----- + lambda*( x^2 - 1 )* -- + x = 0
>         dt^2                        dt         
> 
> so we can plunk 3 in for lambda, this is supposedly an equation from a 
> matlab demo, but i dont have matlab, so i dont know.

Looks like Van der Pol's equation.

> 
> my problem is that this is a 2nd order eq and lsode looks like it only 
> wants 1rst order eq's.
> 
>       Now, i *thought* that any nOrder ode can be represented as an 
> Nsystem of 1rst order diffeq's. I starting to think that i hallucinated 
> this fact because i cant seem to find any example of this in either 
> Boyce/DiPrima or Jordan/Smith, which are the two textbooks on the subject 
> of ode's that i have at my disposal.
> 
>       So, did i hallucinate this? If not, can anybody provide any 
> suggestions as to how i might implement this?
> 
> tks folks, please feel free to tell me if u think this was an 
> inapropriate use of the list.

Seems appropriate?, as long as you are not using this list to do your
homework :-) Anyways, it is a little coincidental that I have been
working on this very same example for an article. So, here it is. This
is rlab, but you ought to be able to translate easily.

vdpol = function ( t , x ) 
{
  global (mu)
  xd[1] = x[1] * mu*(1-x[2]^2) - x[2];
  xd[2] = x[1];
  return xd;
};

(I'll try...)

function xd = vdpol(t,x)
xd(1) = x(1) * mu*(1-x(2)^2) - x(2);
xd(2) = x(1);

The jist is to create 2N 1st order equations from N 2nd order
equations. Most linear systems theory books cover this. Chen's is one
of my favorites (mostly because I suffered through it in Alexandro's
class). The variable substition that gets you there is (hope you can
read TeX):

  \begin{minipage}{8in}

  Most often structural systems of equations are expressed in $2^{nd}$
  order differential equation format:

  \[ \left[ M \right] \left\{ \ddot{x} \right\} + \left[ K \right]
  \left\{ x \right\} = \left\{ F \right\} \]

  A State Space model is an equivilent representation in $1^{st}$
  order differential equation format. The equations are derived via
  a simple coordinate transformation:

  \[ x_1 = x \]
  \[ \dot{x}_1 = \dot{x} = x_2 \]

 To generate a $2N$ set of $1^{st}$ order equations:

  \[ \left\{ \begin{array}{c} \dot{x}_1 \\ \dot{x}_2 \end{array} \right\} 
      = \left[ \begin{array}{cc} 0 & I \\ -M^{-1} K & -M^{-1} C \\
               \end{array} \right]
             \left\{ \begin{array}{c} x_1 \\ x_2 \end{array} \right\} +
             \left[ \begin{array}{c} 0 \\ M^{-1} \\
              \end{array} \right]
              \left\{ \begin{array}{c} F_1 \\ F_2 \end{array}\right\}   \]

  where:

  \[ \begin{array}{ll} x_1  & position \\
                  \dot{x}_1 & velocity \\
                       x_2  & velocity \\
                 \dot{x}_2  & acceleration \\ \end{array} \]

  \end{minipage}


I would highly recommend working through this variable subsititution
until you are very comfortable with it. There is a good chance you
will need it _many_ times in the future.

-ian


reply via email to

[Prev in Thread] Current Thread [Next in Thread]