Results 1 to 6 of 6

Math Help - Runge Kutta, linear differential system

  1. #1
    Member
    Joined
    Mar 2009
    Posts
    76

    Question Runge Kutta, linear differential system

    I need to make a matlab program to find the solutions for 0<=t<=1 for

    x1'(x) = 2x1 -3x2 +4x3 +0x4 -2x5 -2, x1(0)=1
    x2'(x) = x1 - 2x2 - 2x3 +x4 +2x5 -1, x2(0)=-1
    x3'(x) = 2x1 + 4x2 +3x3 +x4 -x5 -2, x3(0)=1
    x4'(x)=-2x1 +0x2 +x3 + 4x4 -3x5 +1, x4(0)=2
    x5'(x)=0x1 -x2 +2x3 -3x4 -2x5 +1, x5(0)=3

    and I made a program, and I got an output:
    w(1)= 94.70989959 w(2)= -5.06974461 w(3)= 81.70881908 w(4)= 7.03658123 w(5)= 12.84918264

    but I have no idea how to tell whether or not I'm right. The other examples I've done have been higher order initial value problems that depended on t... so I used the same kind of scheme... but this one doesn't seem to depend on t... so I'm not sure if I'm suppose to do something different or not?

    Is there a way to get an exact solution for this for me to check to see if I'm right or?
    Last edited by gummy_ratz; December 4th 2010 at 02:30 PM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Mar 2009
    Posts
    76
    Also, for a different example with a higher order equation, my function looked like:
    function a=nonf(t,u)
    a=zeros(1,length(u));
    a(1)=u(2);
    a(2)=u(3);
    a(3)=2.0*cos(t)+u(1)+u(1)*u(2)+2.0*sin(t)*u(3);

    Right now my function for this question looks like:

    function a=nonff(t,u, coef)
    a=zeros(1,length(u));
    for i=1:length(u)
    sum=0;
    for k=1:length(u)
    sum=sum+coef(i,k)*u(k);
    end
    a(i)= sum+coef(i,length(u)+1);
    end

    Would that be right, or would I need something like
    a(1)=u(2);
    a(2)=u(3);
    a(3)=u(4)
    a(4)=u(5)
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by gummy_ratz View Post
    I need to make a matlab program to find the solutions for 0<=t<=1 for

    x1'(x) = 2x1 -3x2 +4x3 +0x4 -2x5 -2, x1(0)=1
    x2'(x) = x1 - 2x2 - 2x3 +x4 +2x5 -1, x2(0)=-1
    x3'(x) = 2x1 + 4x2 +3x3 +x4 -x5 -2, x3(0)=1
    x4'(x)=-2x1 +0x2 +x3 + 4x4 -3x5 +1, x4(0)=2
    x5'(x)=0x1 -x2 +2x3 -3x4 -2x5 +1, x5(0)=3

    and I made a program, and I got an output:
    w(1)= 94.70989959 w(2)= -5.06974461 w(3)= 81.70881908 w(4)= 7.03658123 w(5)= 12.84918264

    but I have no idea how to tell whether or not I'm right. The other examples I've done have been higher order initial value problems that depended on t... so I used the same kind of scheme... but this one doesn't seem to depend on t... so I'm not sure if I'm suppose to do something different or not?

    Is there a way to get an exact solution for this for me to check to see if I'm right or?
    A first observation would be: You are asked for a solution on [0,1] not a single point.

    A second observation might be: This is a linear 5-th order system, it has a known solution (either in matrix form or by expanding to a single 5-th order linear constant coefficient ODE)

    CB
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    Mar 2009
    Posts
    76
    Yeah, my program goes from 0<t<1, that was just my final answer for t=1 when I reached convergence within 8 decimal points. I'm taking numerical analysis now, but I haven't taken differential equations yet, so I'm really not sure, what method could I use to solve this system to see if my runge kutta answer matches up?
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by gummy_ratz View Post
    Yeah, my program goes from 0<t<1, that was just my final answer for t=1 when I reached convergence within 8 decimal points. I'm taking numerical analysis now, but I haven't taken differential equations yet, so I'm really not sure, what method could I use to solve this system to see if my runge kutta answer matches up?
    Sorry but if you have not done differential equations you are not ready for numerical solution of them. It is not our place to provide a course in DEs.

    You could try comparing the RK solution with a solution computed using a simpler method (say Euler) with a smaller step size.

    CB
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Member
    Joined
    Mar 2009
    Posts
    76
    Yeah, I know that there's an easy way to get Maple to find the actual solution to higher order differential equations, and I searched to try to find a way to do it for the linear systems, but I couldn't find one, so I just thought I'd check to see if you guys knew. Thanks, anyways.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Runge-Kutta method for a system, using MATLAB
    Posted in the Differential Equations Forum
    Replies: 1
    Last Post: December 10th 2011, 02:13 AM
  2. Replies: 0
    Last Post: July 20th 2011, 04:04 PM
  3. MATLAB System of ODEs Runge Kutta Fourth order
    Posted in the Differential Equations Forum
    Replies: 1
    Last Post: October 6th 2010, 01:33 AM
  4. Runge Kutta - Second order differential again.
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: January 13th 2010, 07:41 AM
  5. Runge Kutta on second order differential
    Posted in the Differential Equations Forum
    Replies: 5
    Last Post: January 12th 2010, 08:55 AM

Search Tags


/mathhelpforum @mathhelpforum