Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ordinary differential equations

Subject: ordinary differential equations

From: Pag Max

Date: 23 Jan, 2012 14:10:09

Message: 1 of 6

I have a set of ode something like

x={x1,x2}

x1_dd=f(x2_dd)
and
x2_dd=g(x1_dd)

While this can be solved using standard ode45 prodcedure such as

dx(1)=x(2);
dx(2)=f(dx(4))
dx(3)=x(4);
dx(4)=g(dx(2))

I am not sure if it is right from numerical methods perspective because I have LHS of second equation in RHS of first and vice versa.

Any thoughts on this would be appreciaetd.

Subject: ordinary differential equations

From: Torsten

Date: 23 Jan, 2012 16:09:35

Message: 2 of 6

On 23 Jan., 15:10, "Pag Max" <tismarkhanNOS...@gamil.com> wrote:
> I have a set of ode something like
>
> x={x1,x2}
>
> x1_dd=f(x2_dd)
> and
> x2_dd=g(x1_dd)
>
> While this can be solved using standard ode45 prodcedure such as
>
> dx(1)=x(2);
> dx(2)=f(dx(4))
> dx(3)=x(4);
> dx(4)=g(dx(2))
>
> I am not sure if it is right from numerical methods perspective because I have LHS of second equation in RHS of first and vice versa.
>
> Any thoughts on this would be appreciaetd.


Use ode15i for your system of 4 equations from above.

Best wishes
Torsten.

Subject: ordinary differential equations

From: Roger Stafford

Date: 23 Jan, 2012 21:37:50

Message: 3 of 6

"Pag Max" wrote in message <jfjpo1$1bp$1@newscl01ah.mathworks.com>...
> I have a set of ode something like
>
> x={x1,x2}
>
> x1_dd=f(x2_dd)
> and
> x2_dd=g(x1_dd)
> .......
- - - - - - - - - -
  In the two equations, "x2_dd=g(x1_dd)" and "x1_dd=f(x2_dd)", either 'f' and 'g' are inverses of one another or they are not. If the first is true, then there is not sufficient information present to solve the differential equations. You would have in effect only one equation with two unknowns. A ridiculous example of this would be:

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

Now solve for x(t) and y(t). As you can easily see, there is a vast infinitude of possible solutions since dy/dt could be any function of t whatever, as long as dx/dt were twice that.

  On the other hand if 'f' and 'g' are not inverses of one another, there is presumably only one or at least only a finite set of constant number pairs that are possible values for x1_dd and x2_dd, in which case you are dealing with a trivial problem of linear functions of the independent variable where the derivatives are constants.

  In neither of the above situations is the use of 'ode' functions appropriate.

Roger Stafford

Subject: ordinary differential equations

From: Pag Max

Date: 24 Jan, 2012 04:56:10

Message: 4 of 6

Thanks Roger,
No f and g are not inverse of each other but I realize I can reframe my problem
as
x2_dd=inv_f (x1_dd)
and
x1_dd=inv_g(x2_dd),

This was confusing me but I guess you are right, ode is probably not appropriate. What about ode15i as Torsten suggested. Can this be treated as implicit ode.


"Roger Stafford" wrote in message <jfkjve$8b4$1@newscl01ah.mathworks.com>...
> "Pag Max" wrote in message <jfjpo1$1bp$1@newscl01ah.mathworks.com>...
> > I have a set of ode something like
> >
> > x={x1,x2}
> >
> > x1_dd=f(x2_dd)
> > and
> > x2_dd=g(x1_dd)
> > .......
> - - - - - - - - - -
> In the two equations, "x2_dd=g(x1_dd)" and "x1_dd=f(x2_dd)", either 'f' and 'g' are inverses of one another or they are not. If the first is true, then there is not sufficient information present to solve the differential equations. You would have in effect only one equation with two unknowns. A ridiculous example of this would be:
>
> dx/dt = 2*dy/dt
> dy/dt = 1/2*dx/dt
> x(0) = 3
> y(0) = -2
>
> Now solve for x(t) and y(t). As you can easily see, there is a vast infinitude of possible solutions since dy/dt could be any function of t whatever, as long as dx/dt were twice that.
>
> On the other hand if 'f' and 'g' are not inverses of one another, there is presumably only one or at least only a finite set of constant number pairs that are possible values for x1_dd and x2_dd, in which case you are dealing with a trivial problem of linear functions of the independent variable where the derivatives are constants.
>
> In neither of the above situations is the use of 'ode' functions appropriate.
>
> Roger Stafford

Subject: ordinary differential equations

From: Roger Stafford

Date: 24 Jan, 2012 07:52:10

Message: 5 of 6

"Pag Max" wrote in message <jfldla$nh4$1@newscl01ah.mathworks.com>...
> Thanks Roger,
> No f and g are not inverse of each other but I realize I can reframe my problem
> as
> x2_dd=inv_f (x1_dd)
> and
> x1_dd=inv_g(x2_dd),
>
> This was confusing me but I guess you are right, ode is probably not appropriate. What about ode15i as Torsten suggested. Can this be treated as implicit ode.
- - - - - - - - -
  With 'f' and 'g' not inverses of each other, I'll give you an example to illustrate why it would be inappropriate to use any matlab 'ode' function to solve your problem.

  Suppose your differential equations are:

 dx/dt = f(dy/dt) = (dy/dt)^(1/3)
 dy/dt = g(dx/dt) = 1/(1+(dx/dt)^2)
 x(0) = 0
 y(0) = 0

  The solution to the first two equations can be found using 'roots'. Call dx/dt = u and dy/dt = v. We have

 v = 1/(1+u^2)
 u = v^(1/3)
 v = u^3
 u^3 = 1/(1+u^2)
 u^5+u^3-1 = 0
 u = roots([1,0,1,0,0,-1])
 Only one root is real:
 dx/dt = u = .83761977482696
 dy/dt = v = u^3 = 1/(1+u^2) = .58767980285774

  These derivatives are both constant as t varies. Hence we can immediately conclude that

 x(t) = .83761977482696 * t
 y(t) = .58767980285774 * t

without any reference to an 'ode' function. It would be absurd to use it for that purpose.

  The above is characteristic of all cases where 'f' and 'g' are not inverses of one another except that in some cases there may be more than one pair of roots to them, in which case the problem becomes indeterminate as to which pair is going to apply. In any case 'ode' remains entirely unneeded for a problem of this simplistic nature.

Roger Stafford

Subject: ordinary differential equations

From: Pag Max

Date: 24 Jan, 2012 09:45:09

Message: 6 of 6

Got it..
This makes lot of sense..
Thank you so much...

"Roger Stafford" wrote in message <jflnva$mru$1@newscl01ah.mathworks.com>...
> "Pag Max" wrote in message <jfldla$nh4$1@newscl01ah.mathworks.com>...
> > Thanks Roger,
> > No f and g are not inverse of each other but I realize I can reframe my problem
> > as
> > x2_dd=inv_f (x1_dd)
> > and
> > x1_dd=inv_g(x2_dd),
> >
> > This was confusing me but I guess you are right, ode is probably not appropriate. What about ode15i as Torsten suggested. Can this be treated as implicit ode.
> - - - - - - - - -
> With 'f' and 'g' not inverses of each other, I'll give you an example to illustrate why it would be inappropriate to use any matlab 'ode' function to solve your problem.
>
> Suppose your differential equations are:
>
> dx/dt = f(dy/dt) = (dy/dt)^(1/3)
> dy/dt = g(dx/dt) = 1/(1+(dx/dt)^2)
> x(0) = 0
> y(0) = 0
>
> The solution to the first two equations can be found using 'roots'. Call dx/dt = u and dy/dt = v. We have
>
> v = 1/(1+u^2)
> u = v^(1/3)
> v = u^3
> u^3 = 1/(1+u^2)
> u^5+u^3-1 = 0
> u = roots([1,0,1,0,0,-1])
> Only one root is real:
> dx/dt = u = .83761977482696
> dy/dt = v = u^3 = 1/(1+u^2) = .58767980285774
>
> These derivatives are both constant as t varies. Hence we can immediately conclude that
>
> x(t) = .83761977482696 * t
> y(t) = .58767980285774 * t
>
> without any reference to an 'ode' function. It would be absurd to use it for that purpose.
>
> The above is characteristic of all cases where 'f' and 'g' are not inverses of one another except that in some cases there may be more than one pair of roots to them, in which case the problem becomes indeterminate as to which pair is going to apply. In any case 'ode' remains entirely unneeded for a problem of this simplistic nature.
>
> Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us