# Checking membership of 2d region

I want to check whether a point $(x,y)$ belongs to a square region whose x-interval is $[x_1,x_2]$ and y-interval is $[y_1,y_2]$. I defined the 2d region as

Interval[{{x1,x2},{y1,y2}}]


and checked for membership as

IntervalMemberQ[Interval[{{x1,x2},{y1,y2}}],{x,y}]


but the output is always {False, False} no matter the input. For example

IntervalMemberQ[Interval[{{0,1},{0,1}}],{0.5,0.5}]
{False,False} (*output*)


What is going wrong? What is the correct way to deal with this problem? Thanks in advance for any help.

• Interval is strictly 1D. Do RegionMember[ImplicitRegion[0 <= x <= 1 && 0 <= y <= 1, {x, y}], {0.5, 0.5}]. – corey979 Nov 17 '16 at 11:03
• @Kuba , corey979 Unfortunately Mathematica 9.0 does not seem to have that function. – Deep Nov 17 '16 at 11:08
• There are some older topics: mathematica.stackexchange.com/q/9405/5478 – Kuba Nov 17 '16 at 11:12
• @Kuba Thank you very much. I shall check it out. – Deep Nov 17 '16 at 11:17

Interval is for 1-dimensional regions only. For a 2D region, one can do

RegionMember[ImplicitRegion[0 <= x <= 1 && 0 <= y <= 1, {x, y}], {0.5, 0.5}]


True

or, in pre-RegionMember versions, by threading over each dimension with

MapThread[IntervalMemberQ, {{Interval[{0, 1}], Interval[{0, 1}]}, {0.5, 0.5}}]


{True, True}

To get a definite answer, apply And:

And @@ MapThread[IntervalMemberQ, {{Interval[{0, 1}], Interval[{0, 1}]}, {0.5, 0.5}}]


True

Contrary, with {0.5, 1.5}:

MapThread[IntervalMemberQ, {{Interval[{0, 1}], Interval[{0, 1}]}, {0.5, 1.5}}]


{True, False}

so that

And @@ MapThread[IntervalMemberQ, {{Interval[{0, 1}], Interval[{0, 1}]}, {0.5, 1.5}}]


False