# ContourPlot is generating a strange plot

I would like to find out the regions where $f(x,y)=0$ for $$f(x,y):=\frac{2 x^2 y^2+2 x y^2-2 x y+y^4-y^3}{4 x^3 y+2 x^2 y-x^2+x y^2}$$ So I wrote this:

ContourPlot[(-2 x y + 2 x y^2 + 2 x^2 y^2 - y^3 + y^4)/
(-x^2 + 2 x^2 y + 4 x^3 y + x y^2) == 0, {x, -4.5, 4.5}, {y, -4.5, 4.5}]


which resulted in So I thought it's better to just find out where the numerator is zero:

ContourPlot[-2x y + 2x y^2 + 2x^2 y^2 - y^3 + y^4 == 0, {x,-4.5, 4.5}, {y,-4.5, 4.5}] I know the odd behavior of the first plot maybe has something to do with the denominator becoming zero somewhere, but in that case, $f(x,y)$ will tend to infinity and normally, it shouldn't be on the plot. So my question is, how can we prevent such noise from appearing on the plot? Is there any way other than dismissing the denominator?

• @Akku14 that just makes the plot smooth again, and doesn't solve the main problem which is: some lines shouldn't be there. Apr 14, 2018 at 6:51

I don't know what version you are using, but ContourPlot is a bit smarter in 11.3. The result I get here is:

ContourPlot[(-2 x y + 2 x y^2 + 2 x^2 y^2 - y^3 + y^4)/(-x^2 +
2 x^2 y + 4 x^3 y + x y^2) == 0, {x, -4.5, 4.5}, {y, -4.5, 4.5},
PlotPoints -> 50] In your version it appears that ContourPlot assumes there is a zero contour if the function value is positive on one side and negative on the other. So what you're seeing is the boundary of the region where the function is positive:

RegionPlot[(-2 x y + 2 x y^2 + 2 x^2 y^2 - y^3 + y^4)/(-x^2 +
2 x^2 y + 4 x^3 y + x y^2) > 0, {x, -4.5, 4.5}, {y, -4.5, 4.5},
PlotPoints -> 100] The simplest workaround is to do what you already did - remove the denominator.

• I am using version 10.3, and yes, I just tested this on Wolframcloud and got the same result as yours Apr 14, 2018 at 8:39

If you Plot both contours (numerator and denominator)

ContourPlot[{(-2 x y + 2 x y^2 + 2 x^2 y^2 - y^3 + y^4) ==
0, (-x^2 + 2 x^2 y + 4 x^3 y + x y^2) == 0}, {x, -4.5,
4.5}, {y, -4.5, 4.5} , ContourStyle -> {Blue, Red},
MaxRecursion -> 4] you can see some critical intersections where ContourPlot has to deal with 0/0