Results 1 to 5 of 5

Math Help - Newton Method, to solve nonlinear equations, in Matlab

  1. #1
    Newbie
    Joined
    Jan 2009
    Posts
    1

    Newton Method, to solve nonlinear equations, in Matlab

    I have a set of nonlinear equations. And it was proved to have a unique solution. But I can't get the result by using matlab. I thought matlab is using Newton Method. Does anybody know what's wrong about this application?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by unsown View Post
    I have a set of nonlinear equations. And it was proved to have a unique solution. But I can't get the result by using matlab. I thought matlab is using Newton Method. Does anybody know what's wrong about this application?
    Show us what you are trying to do/have done. Otherwise we are just guessing

    .
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Feb 2009
    From
    Liverpool
    Posts
    3

    Exclamation Need Help With Same Problem

    I also have a similar problem and I am having trouble writing a matlab program to solve it. My program so far is as follows:

    Code:
    m=2.0;
    P=4.0;
    Q=5.0;
    
    f=@(x,y) y-((1/m)*((exp(x/m))+(exp(-x/m))));
    g=@(x,y) ((x^2)/(P^2))+((y^2)/(Q^2))-1;
    
    fd1=@(x,y) (1/(m^2))*((exp(x/m))-(exp(-x/m)));
    fd2=@(x,y) 1;
    
    gd1=@(x,y) ((2*x)/(P^2));
    gd2=@(x,y) ((2*y)/(Q^2));
    
    i=1;
    N=100;
    TOL=0.001;
    x=1;
    y=1; 
    
    while i<N
       A=[fd1 fd2; gd1 gd2];
    I know it is far from complete but any advice or suggestions would be very much appreciated.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    You have the sign of df/dx wrong.

    The following works:

    Code:
    m=2.0;
    P=4.0;
    Q=5.0;
     
     
    f=@(x,y) y-(1/m)*(exp(x/m)+exp(-x/m));
    g=@(x,y) (x^2)/(P^2)+(y^2)/(Q^2)-1;
     
     
    fd1=@(x,y) -(1/(m^2))*(exp(x/m)-exp(-x/m));
    fd2=@(x,y) 1;
     
    gd1=@(x,y) (2*x)/(P^2);
    gd2=@(x,y) (2*y)/(Q^2);
     
     
    TOL=0.001;
    x=-1;
    y=-1;
    xx=zeros(2,1);
     
    err=100;
     
     
    while err>TOL
        J=[fd1(x,y) fd2(x,y); gd1(x,y) gd2(x,y)];
     
        xx=[x;y];
        xx=xx-inv(J)*[f(x,y);g(x,y)];  %xx=xx-J\[f(x,y);g(x,y)] would be better
        x1=xx(1);y1=xx(2);
        err=sqrt((x-x1)^2+(y-y1)^2);
        x=x1;y=y1;
    end
     
    xx
    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Feb 2009
    From
    Liverpool
    Posts
    3

    Smile Thank You

    Thank you for that bit of code. I really appreciate the help.
    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. how to solve nonlinear equations in fsolver in matlab
    Posted in the Math Software Forum
    Replies: 0
    Last Post: March 4th 2010, 02:16 PM
  3. Matlab Newton's method help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: November 10th 2009, 04:22 PM
  4. Matlab: Newton-Raphson Method
    Posted in the Math Software Forum
    Replies: 5
    Last Post: September 12th 2009, 03:34 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