I will find an xy dataset satisfying an implicit equation.
5 views (last 30 days)
Show older comments
(x^2 + y^2)^3 + (15*x + 3.3*y)*(x^2 + y^2)^2 + (62.5*x^2 + 20*x*y - 8.37*y^2)*(x^2 + y^2) - 17*x^3 + 11*x^2*y + 17*x*y^2 - 11*y^3 + 432*x^2 - 24*x*y + 67*y^2 - 82*x + 400*y - 1037=0
I have the above equation and I want to obtain 200 xy points satisfying the equation. How can I find?
0 Comments
Accepted Answer
Bruno Luong
on 25 Sep 2023
Edited: Bruno Luong
on 26 Sep 2023
f = @(x,y)(x.^2 + y.^2).^3 + (15.*x + 3.3.*y).*(x.^2 + y.^2).^2 + (62.5.*x.^2 + 20.*x.*y - 8.37.*y.^2).*(x.^2 + y.^2) - 17.*x.^3 + 11.*x.^2.*y + 17.*x.*y.^2 - 11.*y.^3 + 432.*x.^2 - 24.*x.*y + 67.*y.^2 - 82.*x + 400.*y - 1037;
n = 8;
while true
xg = linspace(-8,8,n+1);
yg = linspace(-8,8,n+1);
[Xg,Yg] = meshgrid(xg,yg);
z=f(Xg,Yg);
close all
a = contour(Xg,Yg,z,[0 0]);
if a(2,1) >= 200
break
end
n = 2*n;
end
xy = a(:,2:end);
x = xy(1,:);
y = xy(2,:);
hold on
axis equal
h1=plot(x, y, '.b');
for k=1:size(xy,2)
if ismember(x(k),xg)
y(k) = fzero(@(y) f(x(k),y), y(k));
else
x(k) = fzero(@(x) f(x,y(k)), x(k));
end
end
xy = [x(:), y(:)]
h2=plot(x, y, '.r');
legend([h1 h2],'approximation', 'accurate')
figure
plot(f(x,y)) % should be close to 0
More Answers (0)
See Also
Categories
Find more on Calculus 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!