http://www.mathworks.com/matlabcentral/newsreader/view_thread/297364
MATLAB Central Newsreader  Solving second order differential equations
Feed for thread: Solving second order differential equations
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Thu, 25 Nov 2010 16:48:04 +0000
Solving second order differential equations
http://www.mathworks.com/matlabcentral/newsreader/view_thread/297364#799320
Sridatta Pasumarthy
Hi,<br>
How do i solve four differential equations of second order involving many variables (numerically)?<br>
I have referred van der pol (nonstiff) example in Matlab, but it didn't help much because i couldn't<br>
figure a way to convert these to first order right away. Please help me find a solution.<br>
<br>
Problem Structure<br>
<br>
w' = [k*f(z)] * y'<br>
w * x'' = c*g(z) * y'<br>
w * y'' = f(z) + g(z) * x' + j(z) * z'<br>
w * z'' = c*j(z) * y'<br>
1(1/sqrt(w))=x'^2 + y'^2 + z'^2<br>
<br>
x(0)=0, y(0)=0, z(0)=0, dx/dt(0)=0, dy/dt(0), dz/dt(0)=v<br>
c,k,v are constants.<br>
It also doesn't help that f,g,j are complicated exponential functions based upon z.<br>
<br>
I am supposed to plot 'dw/dz' vs 'z'<br>
<br>
<br>
Thanks,<br>
Sridatta

Thu, 25 Nov 2010 18:19:05 +0000
Re: Solving second order differential equations
http://www.mathworks.com/matlabcentral/newsreader/view_thread/297364#799349
Roger Stafford
"Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icm404$2pn$1@fred.mathworks.com>...<br>
> Hi,<br>
> How do i solve four differential equations of second order involving many variables (numerically)?<br>
> I have referred van der pol (nonstiff) example in Matlab, but it didn't help much because i couldn't<br>
> figure a way to convert these to first order right away. Please help me find a solution.<br>
> <br>
> Problem Structure<br>
> <br>
> w' = [k*f(z)] * y'<br>
> w * x'' = c*g(z) * y'<br>
> w * y'' = f(z) + g(z) * x' + j(z) * z'<br>
> w * z'' = c*j(z) * y'<br>
> 1(1/sqrt(w))=x'^2 + y'^2 + z'^2<br>
> <br>
> x(0)=0, y(0)=0, z(0)=0, dx/dt(0)=0, dy/dt(0), dz/dt(0)=v<br>
> c,k,v are constants.<br>
> It also doesn't help that f,g,j are complicated exponential functions based upon z.<br>
> <br>
> I am supposed to plot 'dw/dz' vs 'z'<br>
> <br>
> <br>
> Thanks,<br>
> Sridatta<br>
       <br>
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.<br>
<br>
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.<br>
<br>
How do you explain this? I am assuming that the functions f, g, and j are all already determined and not unknown functions.<br>
<br>
Roger Stafford

Thu, 25 Nov 2010 22:01:07 +0000
Re: Solving second order differential equations
http://www.mathworks.com/matlabcentral/newsreader/view_thread/297364#799399
Sridatta Pasumarthy
Hi, <br>
thanks for replying again.<br>
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. <br>
<br>
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <icm9ap$5nr$1@fred.mathworks.com>...<br>
> "Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icm404$2pn$1@fred.mathworks.com>...<br>
> > Hi,<br>
> > How do i solve four differential equations of second order involving many variables (numerically)?<br>
> > I have referred van der pol (nonstiff) example in Matlab, but it didn't help much because i couldn't<br>
> > figure a way to convert these to first order right away. Please help me find a solution.<br>
> > <br>
> > Problem Structure<br>
> > <br>
> > w' = [k*f(z)] * y'<br>
> > w * x'' = c*g(z) * y'<br>
> > w * y'' = f(z) + g(z) * x' + j(z) * z'<br>
> > w * z'' = c*j(z) * y'<br>
> > 1(1/sqrt(w))=x'^2 + y'^2 + z'^2<br>
> > <br>
> > x(0)=0, y(0)=0, z(0)=0, dx/dt(0)=0, dy/dt(0), dz/dt(0)=v<br>
> > c,k,v are constants.<br>
> > It also doesn't help that f,g,j are complicated exponential functions based upon z.<br>
> > <br>
> > I am supposed to plot 'dw/dz' vs 'z'<br>
> > <br>
> > <br>
> > Thanks,<br>
> > Sridatta<br>
>        <br>
> 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.<br>
> <br>
> 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.<br>
> <br>
> How do you explain this? I am assuming that the functions f, g, and j are all already determined and not unknown functions.<br>
> <br>
> Roger Stafford

Thu, 25 Nov 2010 22:33:05 +0000
Re: Solving second order differential equations
http://www.mathworks.com/matlabcentral/newsreader/view_thread/297364#799414
Sridatta Pasumarthy
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. <br>
<br>
"Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icmmb3$je7$1@fred.mathworks.com>...<br>
> Hi, <br>
> thanks for replying again.<br>
> 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. <br>
> <br>
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <icm9ap$5nr$1@fred.mathworks.com>...<br>
> > "Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icm404$2pn$1@fred.mathworks.com>...<br>
> > > Hi,<br>
> > > How do i solve four differential equations of second order involving many variables (numerically)?<br>
> > > I have referred van der pol (nonstiff) example in Matlab, but it didn't help much because i couldn't<br>
> > > figure a way to convert these to first order right away. Please help me find a solution.<br>
> > > <br>
> > > Problem Structure<br>
> > > <br>
> > > w' = [k*f(z)] * y'<br>
> > > w * x'' = c*g(z) * y'<br>
> > > w * y'' = f(z) + g(z) * x' + j(z) * z'<br>
> > > w * z'' = c*j(z) * y'<br>
> > > 1(1/sqrt(w))=x'^2 + y'^2 + z'^2<br>
> > > <br>
> > > x(0)=0, y(0)=0, z(0)=0, dx/dt(0)=0, dy/dt(0), dz/dt(0)=v<br>
> > > c,k,v are constants.<br>
> > > It also doesn't help that f,g,j are complicated exponential functions based upon z.<br>
> > > <br>
> > > I am supposed to plot 'dw/dz' vs 'z'<br>
> > > <br>
> > > <br>
> > > Thanks,<br>
> > > Sridatta<br>
> >        <br>
> > 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.<br>
> > <br>
> > 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.<br>
> > <br>
> > How do you explain this? I am assuming that the functions f, g, and j are all already determined and not unknown functions.<br>
> > <br>
> > Roger Stafford

Thu, 25 Nov 2010 23:58:04 +0000
Re: Solving second order differential equations
http://www.mathworks.com/matlabcentral/newsreader/view_thread/297364#799423
Roger Stafford
"Sridatta Pasumarthy" <sridatta1988@gmail.com> wrote in message <icmmb3$je7$1@fred.mathworks.com>...<br>
> Hi, <br>
> thanks for replying again.<br>
> 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. <br>
       <br>
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:<br>
<br>
x'' = (c*g(z) * y') * (1  x'^2  y'^2  z'^2)^2<br>
y'' = (f(z) + g(z) * x' + j(z) * z') * (1  x'^2  y'^2  z'^2)^2<br>
z'' = (c*j(z) * y') * (1  x'^2  y'^2  z'^2)^2<br>
<br>
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'.<br>
<br>
dp/dt = (c*g(z)*q) * (1p^2q^2r^2)^2<br>
dx/dt = p<br>
dq/dt = (f(z)+g(z)*p+j(z)*r) * (1p^2q^2r^2)^2<br>
dy/dt = q<br>
dr/dt = (c*j(z)*q) * (1p^2q^2r^2)^2<br>
dz/dt = r<br>
<br>
See the documentation of the 'ode' functions for the details on this.<br>
<br>
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.<br>
<br>
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.<br>
<br>
Roger Stafford