whats problem in my code for solve newton Rhapson method for equation 4-x^2-y^2 1-exp(x)-y
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abdelrahman Ibrahim Hussein
am 3 Dez. 2020
Kommentiert: Abdelrahman Ibrahim Hussein
am 4 Dez. 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 Kommentare
Antworten (1)
Walter Roberson
am 3 Dez. 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 Kommentare
Walter Roberson
am 3 Dez. 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) ?
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
