Need help in finding all the solutions of non linear ellipse equations using Newtons Method using following code.
Afficher commentaires plus anciens
I am trying to find all the solutions of non linear ellipse equations using Newtons Method using the following code but it only gives me 2 sets of answers no matter the initial guess value.
How can I find all the coordinates of intersection using the following code
func = @(x) [(x(1)+x(2)+2)^2+(x(1)+3)^2-5; 2*(x(1)+3)^2+(x(2)/3)^2-4];
% Jacobian of the Above system calculated
jacobi_func = @(x) [4*x(1)+2*x(2)+10,2*x(1)+2*x(1)+4;4*x(1)+12,2*x(2)/9];
%Define the stopping criteria i-e the tolerance value
tol = 10^-4;
% Define the initial guess
% Note that this effects our final value
% First Coordinate
x = [-1.62;1.38] ;
no_itr = 10 ;
x1 = x;
fnx1 = feval(func,x1);
i = 0;
fprintf(' Iteration| x | y | Error | \n')
while true
norm1 = norm(fnx1);
fprintf('%10d |%10.4f| %10.4f | %10.4d |\n',i,x1(1),x1(2),norm1)
jacob_fnx1 = feval(jacobi_func,x1);
H = jacob_fnx1\fnx1;
x1 = x1 - H;
fnx1 = feval(func,x1);
i = i + 1 ;
norm1 = norm(fnx1);
if i > no_itr && norm1 < tol, break , end
%if norm(fnv1) < error , break , end
end
It only gives me two sets of coordinates but these elllipses have four intersection points
The equations of ellipses are
(x+y+2)^2 + (x+3)^2 = 5
2*(x+3)^2 + (y/3)^2 = 4
Réponse acceptée
Plus de réponses (2)
Alan Stevens
le 22 Fév 2022
Check your Jacobian equations, especially the term:
2*x(1)+2*x(1)+4;
I think this should be
2*x(1)+2*x(2)+4;
1 commentaire
Haseeb Hashim
le 22 Fév 2022
Torsten
le 22 Fév 2022
Maybe a symbolic approach is want you want:
syms x y
res1 = (x+y+2)^2 + (x+3)^2 - 5 == 0;
res2 = 2*(x+3)^2 + (y/3)^2 - 4 == 0;
s = solve([res1,res2],[x,y])
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

