Results 1 to 2 of 2

Math Help - Newton Rhapson method

  1. #1
    Newbie
    Joined
    Feb 2010
    Posts
    1

    Newton Rhapson method

    Okay, so I've completed a Matlab assignment but need to refine a few points. I'd like to add a caption next to Xo stating that it is the 'initial estimate'.
    Also I need to label the columns which appear as output but don't know how. Can anyone help please?

    Here's my code:
    % function takes value for Xo
    % enters Xo into Newton-Rhapson formula
    %Calculates Xnew and determines difference(accuracy)
    %Adjusts value of Xold to value of Xnew
    %Repeats process until satisfactory level of accuracy is achieved
    function[y]= Newton(Xo, epsilon)
    fprintf('%23.15e\n',Xo)
    format long;
    count=0;
    acc=epsilon +1;
    Xold=Xo;
    while acc>=epsilon;
    count= count +1;
    Xnew= Xold-(f)/(fdash);
    acc = abs(Xnew-Xold);
    fprintf('%23.15e %23.15e\n',Xnew,acc)
    Xold= Xnew;
    if count >100;
    error('No convergence after 100 iterations')
    end
    end

    y= Xnew

    %registered value for Xo is entered into function
    %value is returned

    function[f]= f(Xo)
    w= Xold-exp(-(Xold^2));
    f= w;
    %registered value for Xo is entered
    %into derivative of function
    %value is returned
    function[fdash]= fdash(Xo)
    z= 1+(2*Xold*exp(-(Xold^2)))
    fdash=z;
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    fprintf(' initial guess: %23.15e\n',Xo)

    for the other print a string whith the column titles correctly positioned before printing the table.

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Newton Rhapson question
    Posted in the Algebra Forum
    Replies: 2
    Last Post: May 13th 2010, 02:45 PM
  2. Newton's Method
    Posted in the Calculus Forum
    Replies: 2
    Last Post: December 9th 2009, 06:48 PM
  3. Newton's method
    Posted in the Calculus Forum
    Replies: 6
    Last Post: November 13th 2008, 02:24 PM
  4. Newton's method
    Posted in the Calculus Forum
    Replies: 1
    Last Post: November 19th 2007, 03:39 AM
  5. newton method
    Posted in the Calculus Forum
    Replies: 3
    Last Post: November 10th 2007, 07:14 PM

Search Tags


/mathhelpforum @mathhelpforum