Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 5 years ago

Juanjo gravatar image

Suppose that there are k ellipses and let Ri the bounded region limited by the ith-ellipse. Assume that Ri is given by the relation Ei(x,y)0. Consider the function S(x,y)=ki=1sgn(Ei(x,y)). For j=0,,k, a point lying in the intersection of j regions Ri satisfies that S(x,y)=j+(kj)=k2j. So, one has to plot the contours of S for the values k,k+2,k+4,,k to get the points lying in all regions Ri, in all but one regions, in all but two regions,..., in no region Ri, respectively. For example, consider the following code:

E1 = 3*x^2+5*x*y+8*y^2-2*x-30
E2 = x^2-5*x*y+7*y^2+x-3*y-2
E3 = 20*x^2+2*x*y+7*y^2+x-3*y-65
E4 = 6*x^2-5*x*y+28*y^2-2*x+3*y-70
fun = sum(sgn(EE) for EE in [E1,E2,E3,E4])
contour_plot(fun, (x,-5,5), (y,-5,5),contours=[-4,-2,0,2,4],
             plot_points=300, fill=True, cmap="Spectral", colorbar=True)

It yields this image:

image description

Blue points lie in no region bounded by an ellipse; green points lie in only one region; brown points lie in two regions; red points, in three regions; dark red points are the intersection of all regions Ri.

click to hide/show revision 2
No.2 Revision

Suppose that there are k ellipses and let Ri be the bounded region limited by the ith-ellipse. Assume that Ri is given by the relation Ei(x,y)0. Consider the function S(x,y)=ki=1sgn(Ei(x,y)). For j=0,,k, a point lying in the intersection of j regions Ri satisfies that S(x,y)=j+(kj)=k2j. So, one has to plot the contours of S for the values k,k+2,k+4,,k to get the points lying in all regions Ri, in all but one regions, in all but two regions,..., in no region Ri, respectively. For example, consider the following code:

E1 = 3*x^2+5*x*y+8*y^2-2*x-30
E2 = x^2-5*x*y+7*y^2+x-3*y-2
E3 = 20*x^2+2*x*y+7*y^2+x-3*y-65
E4 = 6*x^2-5*x*y+28*y^2-2*x+3*y-70
fun = sum(sgn(EE) for EE in [E1,E2,E3,E4])
contour_plot(fun, (x,-5,5), (y,-5,5),contours=[-4,-2,0,2,4],
             plot_points=300, fill=True, cmap="Spectral", colorbar=True)

It yields this image:

image description

Blue points lie in no region bounded by an ellipse; green points lie in only one region; brown points lie in two regions; red points, in three regions; dark red points are the intersection of all regions Ri. Ri.

click to hide/show revision 3
No.3 Revision

Suppose that there are k ellipses and let Ri be the bounded region limited by the ith-ellipse. Assume that Ri is given by the relation Ei(x,y)0. Consider the function S(x,y)=ki=1sgn(Ei(x,y)). For j=0,,k, a point lying in the intersection of j regions Ri satisfies that S(x,y)=j+(kj)=k2j. So, one has to plot the contours of S for the values k,k+2,k+4,,k to get the points lying in all regions Ri, in all but one regions, in all but two regions,..., in no region Ri, respectively. For example, consider the following code:

E1 = 3*x^2+5*x*y+8*y^2-2*x-30
E2 = x^2-5*x*y+7*y^2+x-3*y-2
E3 = 20*x^2+2*x*y+7*y^2+x-3*y-65
E4 = 6*x^2-5*x*y+28*y^2-2*x+3*y-70
fun = sum(sgn(EE) for EE in [E1,E2,E3,E4])
contour_plot(fun, (x,-5,5), (y,-5,5),contours=[-4,-2,0,2,4],
             plot_points=300, fill=True, cmap="Spectral", colorbar=True)

It yields this image:

image description

Blue points lie in no region bounded by an ellipse; green points lie in only one region; brown points lie in two regions; red points, in three regions; dark red points are the intersection of all regions Ri.

EDIT. In fact, a better and general approach is to plot the function S=ki=11Ri, where 1Ri stands for the characteristic function of Ri. The interesting contours are now 0,1,2,,k.

For the above case, it is clear that 1Ri(x,y)=unit_step(Ei(x,y)). Hence, with the same ellipses, the code

fun = sum(unit_step(-EE) for EE in [E1,E2,E3,E4])
contour_plot(fun, (x,-5,5), (y,-5,5), contours=[0..4],
             plot_points=300, fill=True, cmap="Spectral_r", colorbar=True)

yields this figure:

image description

The color bar now directly says the number of regions to which a point belongs.