Posted By:
31 Mar, 2013 9:20 am PDT

how to find Multi-variable root using Newton-Raphson method in Matlab

I have two nonlinear equations
y = -x^2 + x + 0.5
y + 5xy = x^2

I want to find the root x and y using Newton-Raphson method and the initial guesses of x = y = 1.2.

the output should be: x = 1.23332, y = 0.2122

Attachment:None


% y = -x^2 + x + 0.5
% y + 5xy = x^2
%function

f= @(x) ...
    [ -x(1)^2+x(1)+0.5-x(2) ;...
    x(2)+5*x(1)*x(2)-x(1)^2 ];


%jacobian

J= @(x) ...
    [ -2*x(1)+1 -1 ;...
    5*x(2)-2*x(1) 1+5*x(1) ];

%initial guess:
x=[1.2; 1.2];

tol = 10e-9;
maximum_iter = 100;

% Newton?Raphson method for multidimensional methods

iter = 0;
error=1;
while (error>tol & iter<maximum_iter)
    xold = x;

    x = x - J(x)\f(x);
    error = norm(x-xold)/norm(x);
    iter = iter+1;
end
x_newton_raphson = x

Please watch the video for details***********

Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud