Results 1 to 2 of 2

Math Help - Matlab Newton's method help

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    3

    Matlab Newton's method help

    i have two nonlinear equations
    y=x.^3+x;
    y=((5-x.^2)/2).^(1/3);

    im trying to make a program where u input an (x,y) and it gives you in iterations i.e. (x1,y1) (x2,y2).. and it solves for the intersection. im confused on how to do this with 2 equations im only familiar with doing it with 1

    edit:
    basically have to do this
    Use the Newton’s method to obtain the first (x1, y1), second (x2,y2) , third (x3,y3) , …, up to tenth (x10,y10) improvements of the solution. Is this a convergent sequence? Otherwise change the initial guess (x,y) until you get a convergent sequence.



    i did this to solve for the point
    >> x=linspace(0,2);
    >> y1=x.^3+x;
    >> y2=((5-x.^2)/2).^(1/3);
    >> plot(x,y1,x,y2)
    >> f1 = @(x) ((5-x.^2)/2).^(1/3);
    >> f2 = @(x) (x.^3+x);
    >> pt = fzero(@(x) f1(x)-f2(x),.8)

    pt =

    0.7950

    >> coord = [pt,f1(pt)]

    coord =

    0.7950 1.2974
    Last edited by nick61416; November 10th 2009 at 11:36 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    Use a for loop with a simple implementation of the Newton-Raphson method.

    Code:
    clear;clc;
    x = 2;%initial guess
    iters = 10;%num of iterations
    h = 1e-6;%step size
    f = @(x) ((5-x.^2)/2).^(1/3)-(x.^3+x);
    i = 0;
    while i <= iters;
        fprintf('Iteration %g :  x = %0.3f\n',i,x)
        df = (f(x+h)-f(x))/h;
        x = x-f(x)/df;
        i = i + 1;    
    end
    Results in:
    Code:
    Iteration 0 : x = 2.000
    Iteration 1 : x = 1.345
    Iteration 2 : x = 0.959
    Iteration 3 : x = 0.814
    Iteration 4 : x = 0.795
    Iteration 5 : x = 0.795
    Iteration 6 : x = 0.795
    Iteration 7 : x = 0.795
    Iteration 8 : x = 0.795
    Iteration 9 : x = 0.795
    Iteration 10 : x = 0.795
    Elbarto
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab- Newton's method
    Posted in the Math Software Forum
    Replies: 4
    Last Post: March 31st 2010, 07:50 PM
  2. Newton's Method
    Posted in the Calculus Forum
    Replies: 1
    Last Post: December 6th 2009, 04:10 PM
  3. Matlab: Newton-Raphson Method
    Posted in the Math Software Forum
    Replies: 5
    Last Post: September 12th 2009, 03:34 PM
  4. Newton Method, to solve nonlinear equations, in Matlab
    Posted in the Math Software Forum
    Replies: 4
    Last Post: February 18th 2009, 02:27 PM
  5. Help with Newton's Method in Matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2009, 11:35 PM

Search Tags


/mathhelpforum @mathhelpforum