Results 1 to 5 of 5

Math Help - Matlab- Newton's method

  1. #1
    Rui
    Rui is offline
    Newbie
    Joined
    Mar 2008
    Posts
    13

    Matlab- Newton's method

    1. Use Newton's method to compute 10th root of 2 accurate to eight decimal places.
    I don't know how to use Newton's method... I tried nthroot(2,10)and it gets the right answer, but it's not newton's method.

    2. Find all the roots correct to six decimal places of the equation
    x^2(4-x^2) =4/(x^2+1)
    making some stage of newton_iteration and ezplot.
    No idea on how to do this one.


    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Rui View Post
    1. Use Newton's method to compute 10th root of 2 accurate to eight decimal places.
    I don't know how to use Newton's method... I tried nthroot(2,10)and it gets the right answer, but it's not newton's method.

    We want to find x such that x^{10}=2, that is we want roots of f(y)=y^{10}-2.

    Newtons method is the itteration:

     <br />
x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}<br />

    So in this case it is:

     <br />
x_{n+1}=x_n-\frac{x_n^{10}-2}{10x^9_n}<br />

    The Matlab code will look something like:

    Code:
    function xn=tenthroot(n,x0)
    %
    %  n is the number we want the 10-th root of
    %  x0 is an initial guess
    %
     
       xn=x0;del=100
       while del>1e-12
          xo=xn;
          xn=xo-(xo^10-n)/(10*xo^9);
          del=abs(xn-xo);
       end %while
    This is untested code, so try it first in the debugger or whatever

    RonL
    Last edited by CaptainBlack; April 23rd 2008 at 04:49 AM. Reason: correcting LaTeX
    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 Rui View Post
    2. Find all the roots correct to six decimal places of the equation
    x^2(4-x^2) =4/(x^2+1)
    making some stage of newton_iteration and ezplot.
    No idea on how to do this one.

    You want the roots of:

    f(x)=x^2(4-x^2) - 4/(x^2+1)=0

    Plot this over an appropriate range to locate them approximately to serve as initial guesses in the iteration.

    The other post gives the form of Newton iteration, so you should be able to adapt what is in that post.

    RonL
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by CaptainBlack View Post
    We want to find x such that x^{10}=2, that is we want roots of f(y)=y^{10}-2.

    Newtons method is the itteration:

     <br />
x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}<br />

    So in this case it is:

     <br />
x_{n+1}=x_n-\frac{x_n^{10}-2}{10x^9_n}<br />

    The Matlab code will look something like:

    Code:
    function xn=tenthroot(n,x0)
    %
    %  n is the number we want the 10-th root of
    %  x0 is an initial guess
    %
     
       xn=x0;del=100
       while del>1e-12
          xo=xn;
          xn=xo-(xo^10-n)/(10*xo^9);
          del=abs(xn-xo);
       end %while
    This is untested code, so try it first in the debugger or whatever

    RonL
    Now I don't have Matlab on this machine, but the algorithm can be tested on other systems, so here is the EuMathT version:

    Code:
    
    Processing configuration file.
    Done.
    >
    >function tenth(n,x0)
    $  xn=x0;del=100;
    $  repeat
    $    xo=xn;
    $    xn=xo-(xo^10-n)/(10*xo^9);
    $    del=abs(xn-xo);
    $    if del<1e-12
    $       break
    $    endif
    $  end ..repeat
    $  return xn
    $endfunction
    >
    >tt=tenth(20,1)
          1.34928 
    >tt^10
               20 
    >
    RonL
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Super Member Anonymous1's Avatar
    Joined
    Nov 2009
    From
    Big Red, NY
    Posts
    517
    Thanks
    1
    Quote Originally Posted by CaptainBlack View Post
    We want to find x such that x^{10}=2, that is we want roots of f(y)=y^{10}-2.

    Newtons method is the itteration:

     <br />
x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}<br />

    So in this case it is:

     <br />
x_{n+1}=x_n-\frac{x_n^{10}-2}{10x^9_n}<br />

    The Matlab code will look something like:

    Code:
    function xn=tenthroot(n,x0)
    %
    %  n is the number we want the 10-th root of
    %  x0 is an initial guess
    %
     
       xn=x0;del=100
       while del>1e-12
          xo=xn;
          xn=xo-(xo^10-n)/(10*xo^9);
          del=abs(xn-xo);
       end %while
    This is untested code, so try it first in the debugger or whatever

    RonL
    What do you know, this post came in handy years later. Thanks!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab Newton's method help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: November 10th 2009, 04:22 PM
  2. Matlab: Newton-Raphson Method
    Posted in the Math Software Forum
    Replies: 5
    Last Post: September 12th 2009, 03:34 PM
  3. Newton Method, to solve nonlinear equations, in Matlab
    Posted in the Math Software Forum
    Replies: 4
    Last Post: February 18th 2009, 02:27 PM
  4. Help with Newton's Method in Matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2009, 11:35 PM
  5. Newton's Method on TI-84
    Posted in the Calculus Forum
    Replies: 1
    Last Post: April 7th 2008, 11:32 AM

Search Tags


/mathhelpforum @mathhelpforum