## Plotting implicit equation with fimplicit

### Jay (view profile)

on 11 Feb 2019
Latest activity Commented on by Torsten

### Torsten (view profile)

on 11 Feb 2019
Accepted Answer by Torsten

### Torsten (view profile)

Hello
I have tried to plot this implicit equation. But when I tried it, the plot is showing empty.
Here is the code I used to plot. Could anyone help me with this.
clc
syms f(x,y)
n = 8;
a1 = 1.0086*y - 0.9216*(x - y);
b1 = 1.0107*(-x) - 1.0086*(y);
c1 = 0.9216*(x - y) - 1.0107*(-x);
h1 = 0.5877*(161.65);
I3 = ((a1.* b1.*c1)/(54))-((b1.*(h1.^2))/(6));
I2 = ((h1.^2)/(3))+((a1.^2 + b1.^2 + c1.^2)/(54));
th = acos(I3/(I2.^(3/2)));
v1 = ((2*th)+pi)/6;
an1 = (abs(2*cos(v1)))^n;
an2 = (abs(2*cos((2*th+3*pi)/6)))^n;
an3 = (abs(2*cos((2*th+5*pi)/6)))^n;
f(x,y) = ((3*I2).^(n/2)) * (an1 + an2 + an3) - (2*(189.32)^8);
fimplicit(f)

R2018b

### Torsten (view profile)

on 11 Feb 2019

function main
fimplicit (@(x,y)f(x,y))
end
function fun = f(x,y)
n = 8;
a1 = 1.0086*y - 0.9216*(x - y);
b1 = 1.0107*(-x) - 1.0086*(y);
c1 = 0.9216*(x - y) - 1.0107*(-x);
h1 = 0.5877*(161.65);
I3 = ((a1.* b1.*c1)/(54))-((b1.*(h1.^2))/(6));
I2 = ((h1.^2)/(3))+((a1.^2 + b1.^2 + c1.^2)/(54));
th = acos(I3./(I2.^(3/2)));
v1 = ((2*th)+pi)/6;
an1 = (abs(2*cos(v1))).^n;
an2 = (abs(2*cos((2*th+3*pi)/6))).^n;
an3 = (abs(2*cos((2*th+5*pi)/6))).^n;
fun = ((3*I2).^(n/2)).* (an1 + an2 + an3) - (2*(189.32)^8);
end
Resonable limits for plotting are required - no zeros are found in the default range [-5:5] for x and y.

Torsten

### Torsten (view profile)

on 11 Feb 2019
fimplicit (@(x,y)f(x,y),[-200 200 -150 150])
Jay

### Jay (view profile)

on 11 Feb 2019
Hello Torsten
It works. But it is not working with other limits. Can you explain why so?
Thank you.
Torsten

### Torsten (view profile)

on 11 Feb 2019
It "works" as long as the object is contained in the box defined by the specified limits for x and y. ### John D'Errico (view profile)

Answer by John D'Errico

### John D'Errico (view profile)

on 11 Feb 2019
Edited by John D'Errico

### John D'Errico (view profile)

on 11 Feb 2019

Easy enough. Try this, for example.
vpasolve(f(1,y))
ans =
-80.224189505722446658042301607259
vpasolve(f(-20,y))
ans =
63.634253282860063957543062643774
Hmm. So [1,-80] is roughly a solution. That should be a good hint as to where to have fimplicit look.
fimplicit(f,[-150,150,-150,150])
axis equal
grid on The problem was fimplicit looks by default in a rather narrow set of limits on x and y. It cannot know where it SHOULD be looking, and computer programs can sometimes be so clueless. Since fimplicit just found no solutions at all in the domain it was looking by default, you saw an empty figure. Sometimes you need to give even a computer a nudge in the right direction.