6
$\begingroup$

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

odd

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}]

normal

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?

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

2 Answers 2

7
$\begingroup$

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]

enter image description here

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]

enter image description here

The simplest workaround is to do what you already did - remove the denominator.

$\endgroup$
1
  • $\begingroup$ I am using version 10.3, and yes, I just tested this on Wolframcloud and got the same result as yours $\endgroup$
    – polfosol
    Apr 14, 2018 at 8:39
4
$\begingroup$

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]    

enter image description here

you can see some critical intersections where ContourPlot has to deal with 0/0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.