Results 1 to 3 of 3

Math Help - Euler's method

  1. #1
    Senior Member chella182's Avatar
    Joined
    Jan 2008
    Posts
    267

    Euler's method

    The question goes...

    Implement Euler's method in order to find a numerical solution of the equation

    y'=y^2-2xy+1+x^2 which satisfies y(0)=-1

    integrate over the domain 0\leq x\leq 5, choosing suffiecently small step length.

    Then I've gotta plot a graph on this program, which I'll be able to do if I had a clue how to do the question can anyone help?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Joined
    Dec 2008
    From
    Scotland
    Posts
    901
    Quote Originally Posted by chella182 View Post
    The question goes...

    Implement Euler's method in order to find a numerical solution of the equation

    y'=y^2-2xy+1+x^2 which satisfies y(0)=-1

    integrate over the domain 0\leq x\leq 5, choosing suffiecently small step length.

    Then I've gotta plot a graph on this program, which I'll be able to do if I had a clue how to do the question can anyone help?
    Haha. You must do Maths at Newcastle, aye?

    The same as Matt.

    I had to help him with it too :P.

    Euler's method says that, given a step size h, and a differential equation  y' = f(x,y) then the solution to a differential equation is given by:

     y_{k+1} = y_k + h \times \big(f(x_k,y_k)\big)

    And that

     x_{k+1} = x_k + h

    So for you, your equations would be:

     y_{k+1} = y_k + h \times \big(y^2 - 2xy + x^2+1\big)

     x_{k+1} = x_k + h

    So your program should look something like this:

    Code:
    set x(1) = 0
    set y(1) = -1
    set h = 0.01
    
    for k = 2 to 501 in steps of 1
         y(k) = y(k-1)+h*((y(k-1))^2-2*(x(k-1))*(y(k-1))+1+(x(k-1))^2);
         x(k) = x(k-1)+h;
    end
    
    plot(x,y)
    Of course, I'm fairly sure you guys use maple, whereas I am more conversant in MatLab, so I can't give the program to you in Maple!

    However, in matlab, it looks like this:

    Code:
    x(1) = 0;
    y(1) = -1;
    h= 0.01;
    
    for i = 2:1:501;
         y(i) = y(i-1)+h*((y(i-1))^2-2*(x(i-1))*(y(i-1))+1+(x(i-1))^2);
     x(i) = x(i-1)+h;
    end
    
    plot(x,y,'r')
    If I'm talking out of context here, you may be better to talk to Matt. He uses this forum, goes by the name Mitch something! He'll know.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Senior Member chella182's Avatar
    Joined
    Jan 2008
    Posts
    267
    I do indeed & I know Matthew

    I don't remember doing Euler's method at all this semester so it confused me when it came up. Thanks though
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Euler method
    Posted in the Differential Equations Forum
    Replies: 2
    Last Post: May 11th 2011, 05:59 AM
  2. Euler's method
    Posted in the Calculus Forum
    Replies: 0
    Last Post: March 8th 2010, 05:48 PM
  3. Euler method vs RK4
    Posted in the Differential Equations Forum
    Replies: 2
    Last Post: January 7th 2010, 03:21 PM
  4. Euler's Method
    Posted in the Differential Equations Forum
    Replies: 2
    Last Post: November 9th 2009, 08:20 AM
  5. Euler's Method
    Posted in the Advanced Applied Math Forum
    Replies: 1
    Last Post: July 20th 2007, 11:07 AM

Search Tags


/mathhelpforum @mathhelpforum