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

1 view (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

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.

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!