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:
Solving second order differential equations

Subject: Solving second order differential equations

From: Sridatta Pasumarthy

Date: 25 Nov, 2010 16:48:04

Message: 1 of 5

Hi,
How do i solve four differential equations of second order involving many variables (numerically)?
I have referred van der pol (non-stiff) example in Matlab, but it didn't help much because i couldn't
figure a way to convert these to first order right away. Please help me find a solution.

Problem Structure
----------------------------------
w' = [k*f(z)] * y'
w * x'' = c*g(z) * y'
w * y'' = f(z) + g(z) * x' + j(z) * z'
w * z'' = c*j(z) * y'
1-(1/sqrt(w))=x'^2 + y'^2 + z'^2

x(0)=0, y(0)=0, z(0)=0, dx/dt(0)=0, dy/dt(0), dz/dt(0)=v
c,k,v are constants.
It also doesn't help that f,g,j are complicated exponential functions based upon z.

I am supposed to plot 'dw/dz' vs 'z'
----------------------------------

Thanks,
Sridatta

Subject: Solving second order differential equations

From: Roger Stafford

Date: 25 Nov, 2010 18:19:05

Message: 2 of 5

"Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icm404$2pn$1@fred.mathworks.com>...
> Hi,
> How do i solve four differential equations of second order involving many variables (numerically)?
> I have referred van der pol (non-stiff) example in Matlab, but it didn't help much because i couldn't
> figure a way to convert these to first order right away. Please help me find a solution.
>
> Problem Structure
> ----------------------------------
> w' = [k*f(z)] * y'
> w * x'' = c*g(z) * y'
> w * y'' = f(z) + g(z) * x' + j(z) * z'
> w * z'' = c*j(z) * y'
> 1-(1/sqrt(w))=x'^2 + y'^2 + z'^2
>
> x(0)=0, y(0)=0, z(0)=0, dx/dt(0)=0, dy/dt(0), dz/dt(0)=v
> c,k,v are constants.
> It also doesn't help that f,g,j are complicated exponential functions based upon z.
>
> I am supposed to plot 'dw/dz' vs 'z'
> ----------------------------------
>
> Thanks,
> Sridatta
- - - - - - - -
  Hello again Sridatta. You said "four differential equations" but I count five! With only the four variables x, y, z, and w, that seems to be one too many equations to satisfy.

  Think of it this way. If w were being held fixed, the three middle equations involving x'', y'', and z'' would suffice for solving for x, y, and z. Allowing w to vary according to the first equation would again constitute a solvable problem of four equations and four unknowns. I see no reason why that fifth equation should then hold true.

  How do you explain this? I am assuming that the functions f, g, and j are all already determined and not unknown functions.

Roger Stafford

Subject: Solving second order differential equations

From: Sridatta Pasumarthy

Date: 25 Nov, 2010 22:01:07

Message: 3 of 5

Hi,
thanks for replying again.
f,g,h are not unknowns. i know the expressions for them. (they stand out for some forms of the electric and magnetic field components of an electromagnetic wave in a waveguide). fifth equation defines w in terms of x' , y' , z'. i don't think the first equation is needed for solving because it is related to the final answer i am supposed to find. i just gave it assuming that it might be of extra help. the principal problem constitutes final four equations.

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <icm9ap$5nr$1@fred.mathworks.com>...
> "Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icm404$2pn$1@fred.mathworks.com>...
> > Hi,
> > How do i solve four differential equations of second order involving many variables (numerically)?
> > I have referred van der pol (non-stiff) example in Matlab, but it didn't help much because i couldn't
> > figure a way to convert these to first order right away. Please help me find a solution.
> >
> > Problem Structure
> > ----------------------------------
> > w' = [k*f(z)] * y'
> > w * x'' = c*g(z) * y'
> > w * y'' = f(z) + g(z) * x' + j(z) * z'
> > w * z'' = c*j(z) * y'
> > 1-(1/sqrt(w))=x'^2 + y'^2 + z'^2
> >
> > x(0)=0, y(0)=0, z(0)=0, dx/dt(0)=0, dy/dt(0), dz/dt(0)=v
> > c,k,v are constants.
> > It also doesn't help that f,g,j are complicated exponential functions based upon z.
> >
> > I am supposed to plot 'dw/dz' vs 'z'
> > ----------------------------------
> >
> > Thanks,
> > Sridatta
> - - - - - - - -
> Hello again Sridatta. You said "four differential equations" but I count five! With only the four variables x, y, z, and w, that seems to be one too many equations to satisfy.
>
> Think of it this way. If w were being held fixed, the three middle equations involving x'', y'', and z'' would suffice for solving for x, y, and z. Allowing w to vary according to the first equation would again constitute a solvable problem of four equations and four unknowns. I see no reason why that fifth equation should then hold true.
>
> How do you explain this? I am assuming that the functions f, g, and j are all already determined and not unknown functions.
>
> Roger Stafford

Subject: Solving second order differential equations

From: Sridatta Pasumarthy

Date: 25 Nov, 2010 22:33:05

Message: 4 of 5

also, i should probably mention that f,g,j are exponential equations of the simple form A*exp(B*z) where A,B are constants.

"Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icmmb3$je7$1@fred.mathworks.com>...
> Hi,
> thanks for replying again.
> f,g,h are not unknowns. i know the expressions for them. (they stand out for some forms of the electric and magnetic field components of an electromagnetic wave in a waveguide). fifth equation defines w in terms of x' , y' , z'. i don't think the first equation is needed for solving because it is related to the final answer i am supposed to find. i just gave it assuming that it might be of extra help. the principal problem constitutes final four equations.
>
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <icm9ap$5nr$1@fred.mathworks.com>...
> > "Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icm404$2pn$1@fred.mathworks.com>...
> > > Hi,
> > > How do i solve four differential equations of second order involving many variables (numerically)?
> > > I have referred van der pol (non-stiff) example in Matlab, but it didn't help much because i couldn't
> > > figure a way to convert these to first order right away. Please help me find a solution.
> > >
> > > Problem Structure
> > > ----------------------------------
> > > w' = [k*f(z)] * y'
> > > w * x'' = c*g(z) * y'
> > > w * y'' = f(z) + g(z) * x' + j(z) * z'
> > > w * z'' = c*j(z) * y'
> > > 1-(1/sqrt(w))=x'^2 + y'^2 + z'^2
> > >
> > > x(0)=0, y(0)=0, z(0)=0, dx/dt(0)=0, dy/dt(0), dz/dt(0)=v
> > > c,k,v are constants.
> > > It also doesn't help that f,g,j are complicated exponential functions based upon z.
> > >
> > > I am supposed to plot 'dw/dz' vs 'z'
> > > ----------------------------------
> > >
> > > Thanks,
> > > Sridatta
> > - - - - - - - -
> > Hello again Sridatta. You said "four differential equations" but I count five! With only the four variables x, y, z, and w, that seems to be one too many equations to satisfy.
> >
> > Think of it this way. If w were being held fixed, the three middle equations involving x'', y'', and z'' would suffice for solving for x, y, and z. Allowing w to vary according to the first equation would again constitute a solvable problem of four equations and four unknowns. I see no reason why that fifth equation should then hold true.
> >
> > How do you explain this? I am assuming that the functions f, g, and j are all already determined and not unknown functions.
> >
> > Roger Stafford

Subject: Solving second order differential equations

From: Roger Stafford

Date: 25 Nov, 2010 23:58:04

Message: 5 of 5

"Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icmmb3$je7$1@fred.mathworks.com>...
> Hi,
> thanks for replying again.
> f,g,h are not unknowns. i know the expressions for them. (they stand out for some forms of the electric and magnetic field components of an electromagnetic wave in a waveguide). fifth equation defines w in terms of x' , y' , z'. i don't think the first equation is needed for solving because it is related to the final answer i am supposed to find. i just gave it assuming that it might be of extra help. the principal problem constitutes final four equations.
- - - - - - - -
  If you discard the first equation, then you can express this problem as a system of three second order differential equations in three unknown variables:

x'' = (c*g(z) * y') * (1 - x'^2 - y'^2 - z'^2)^2
y'' = (f(z) + g(z) * x' + j(z) * z') * (1 - x'^2 - y'^2 - z'^2)^2
z'' = (c*j(z) * y') * (1 - x'^2 - y'^2 - z'^2)^2

  If you wish to solve it numerically for variables x, y, and z, you would express it with six equations. Call p = x', q = y', and r = z'.

dp/dt = (c*g(z)*q) * (1-p^2-q^2-r^2)^2
dx/dt = p
dq/dt = (f(z)+g(z)*p+j(z)*r) * (1-p^2-q^2-r^2)^2
dy/dt = q
dr/dt = (c*j(z)*q) * (1-p^2-q^2-r^2)^2
dz/dt = r

See the documentation of the 'ode' functions for the details on this.

  Notice that the variables x and y never appear in the earlier equations, so if you don't need them specifically, you could simple solve for p, q, and z using only four equations, leaving dx/dt and dy/dt out.

  I see no particular reason why your original first equation should hold true as to the derivative of w as obtained from the fifth equation unless you were especially lucky in your defined functions, f, g, and j and constant c.

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