Results 1 to 3 of 3

Thread: Matlab and Newtons method

  1. #1
    Member
    Joined
    Mar 2016
    From
    Australia
    Posts
    170

    Matlab and Newtons method

    Hi,

    i have to to use newtons method to solve for a zero solution of f(x) = x-e^-x^-2.

    I get the iteration formula: x(k+1) = xk - f(xk)/(f'xk) and a first guess that x(0) = 0.5.

    can anyone help me write the code for the next iterations (does it contain a for loop?)

    i am am new to calculus (kind of did it 20 years ago) and still learning Matlab (actually for my other unit!)

    Any help appreciated

    kind regards
    Beetle
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    skeeter's Avatar
    Joined
    Jun 2008
    From
    North Texas
    Posts
    16,155
    Thanks
    3672

    Re: Matlab and Newtons method

    Quote Originally Posted by Beetle37 View Post
    i have to to use newtons method to solve for a zero solution of f(x) = x-e^-x^-2.
    f(x) = x-e^-x^-2 is interpreted as $f(x)=x-e^{-x^{-2}} = x - e^{-\frac{1}{x^2}}$

    that's not the function you've referred to in your other posts re: the IVT & Newton's method

    your function is f(x) = x - e^(-x^2) ... $f(x) = x - e^{-x^2}$

    pay attention to detail to avoid further confusion.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member
    Joined
    Mar 2016
    From
    Australia
    Posts
    170

    Re: Matlab and Newtons method

    Hi,

    I seemed to have lost my reply to this post so; below is what I have tried to program by adapting an example we had in the notes. There is an issue in writing the formula (amongst other things). I did have it prompting me to input the initial guess and number of iterations however have seemed to have lost that and now get an error in the formula line. I have checked my indices and think they are now correct as pointed out above.

    The question isa) Without doing a sketch, show that the equation f(x) = x − e^(−x^2)

    has at least one solution on the interval [0, 2].
    [Hint: Use a theorem discussed in lectures, or see Section 1.8 of Calculus (8th ed) by Stewart.
    Ensure the conditions of the theorem are satisfied.]

    (b) Use Newton’s method to find this zero accurate to 3 decimal places. You should include a
    sketch of the function, Newton’s iteration formula, and the list of iterates. [Use a computer
    if possible, e.g. a spreadsheet or MatLab.]

    and the script I am trying to enter currently looks like this:
    %Use Newtton's Method to find a non-zero number such that f(x) =
    %x-e(^(x^2);
    clear;
    x_=input ('Enter initial guess x_0):');
    num = input ('Enter number of iterations');
    x = -0.1:0.001:2;
    k=0;
    fprintf('x = %f\n', x);
    for k=num
    x = x-(x-e^(-x^2)/(1+2*x.e^(-x^2);
    disp ('k num x')
    end

    Any help would be appreciated.

    Cheers
    Beetle
    Last edited by Beetle37; Mar 26th 2016 at 05:25 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Newtons Method Help??
    Posted in the Calculus Forum
    Replies: 3
    Last Post: Nov 8th 2011, 03:41 PM
  2. Newtons method?
    Posted in the Calculus Forum
    Replies: 2
    Last Post: Aug 3rd 2011, 11:48 AM
  3. Newtons method help?
    Posted in the Differential Geometry Forum
    Replies: 15
    Last Post: Dec 13th 2010, 11:33 PM
  4. Newtons method for matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: Oct 28th 2009, 04:42 PM
  5. Newtons method
    Posted in the Calculus Forum
    Replies: 1
    Last Post: Jan 13th 2009, 08:30 AM

Search Tags


/mathhelpforum @mathhelpforum