Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Newton Raphson Method on Fortran90

  1. Dec 2, 2012 #1
    Here's what I need to do:

    "Compare the effectiveness of the bisection method and Newton’s method for the
    equation x^3−2x−2 = 0 which has a single root between x=−4 and x = 2."

    So far I've done
    ok. this is working but of course I need to do iteration which I don't know how. Can someone teach me please? I'm trying the Newton-Raphson Method first.

    Thanks for the help in advance.

    EDITED: Sorry, I posted the wrong pic earlier. Here's the correct one.
    Last edited: Dec 2, 2012
  2. jcsd
  3. Dec 2, 2012 #2
    Code (Text):

    program nr
    real:: x, xnew, err

    write(*,*) "starting x?:"
    read(*,*) x

        xnew = x - ( (x**3 - (2*x) - 2) / ( ( 3*(x**2) )-2) )
        err = 100*abs( (xnew-x)/x )
        x = xnew
        write(*,*) "x = ", xnew, "  error = ", err
        if (err < 0.000001) exit
    end do

    end program nr
  4. Dec 3, 2012 #3
    thanks :))) Is that the iteration already?
  5. Dec 3, 2012 #4

    Isn't it? Run it and verify the solution
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook