whats problem in my code for solve newton Rhapson method for equation 4-x^2-y^2 1-exp(x)-y
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Abdelrahman Ibrahim Hussein
el 3 de Dic. de 2020
Comentada: Abdelrahman Ibrahim Hussein
el 4 de Dic. de 2020
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 comentarios
Respuestas (1)
Walter Roberson
el 3 de Dic. de 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 comentarios
Walter Roberson
el 3 de Dic. de 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) ?
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!