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

1 次查看(过去 30 天)
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

回答(1 个)

Walter Roberson
Walter Roberson 2020-12-3
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 个评论
Walter Roberson
Walter Roberson 2020-12-3
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) ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by