MATLAB Answers

whats problem in my code for solve newton Rhapson method for equation 4-x^2-y^2 1-exp(x)-y

16 views (last 30 days)
clc
clear
format long
n=10; x(1)=1; y(1)=-1.7;
for i=1:n
f(x(i),y(i))=4-x(i)^2-y(i)^2;
g(x(i),y(i))=1-exp(x(i))-y(i);
fx(i)=4-2*x(i);
gx(i)=-exp(x(i));
fy(i)=-2*y(i);
gy(i)=-1;
x(i+1)=x(i)-(f(i)*gy(i)-fy(i)*g(i))/(fx(i)*gy(i)-fy(i)*gx(i));
y(i+1)=y(i)-(fx(i)*g(i)-f(i)*gy(i))/(fx(i)*gy(i)-fy(i)*gx(i));
end

  0 Comments

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 3 Dec 2020
Suppose we could find some way to make your assignments to f(x,y) and g(x,y) work out. Then what would you do with the results? You never use f(x,y) or g(x,y) in your calculations: you only use f(i) and g(i) . Perhaps you should not be assigning to f(x(i),y(i)) and g(x(i),y(i)) and should be assigning to f(i) and g(i) ?

  3 Comments

Walter Roberson
Walter Roberson on 3 Dec 2020
Repeating myself:
Perhaps you should not be assigning to f(x(i),y(i)) and g(x(i),y(i)) and should be assigning to f(i) and g(i) ?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by