3
$\begingroup$

Consider two domains:

domain1 = Rectangle[{-2.5, -2.5}, {2.5, 2.5}];
domain2[R_] := Disk[{0, 0}, R]

I would like to check whether the second domain is completely included in the first domain. My attempt is

condition[R_] := If[domain2[R] \[Element] domain1, 1, 0]
condition[1]

However, it does not work, as the commands used are incorrect. Could you please tell me how to do this?

$\endgroup$

2 Answers 2

4
$\begingroup$
domain1 = Rectangle[{-2.5, -2.5}, {2.5, 2.5}];
domain2[R_] := Disk[{0, 0}, R]

You can use RegionWithin:

ClearAll[condition]
condition[R_] := Boole @ RegionWithin[domain1, domain2[R]]

{condition[1], condition[3]}
{1, 0}

You can also use a combination of ForAll and Resolve:

ClearAll[conditionB]
conditionB[R_] := Resolve[ForAll[x, Implies[x ∈ domain2[R], x ∈ domain1]], Reals]

{conditionB[1], conditionB[2], conditionB[3]}
 {True, True, False}
ClearAll[conditionC]
conditionC[R_] := Resolve[ForAll[x, ! x ∈ domain2[R] || x ∈ domain1], Reals]

{conditionC[1], conditionC[2], conditionC[3]}
{True, True, False}
$\endgroup$
4
$\begingroup$
domain1 = Rectangle[{-2.5, -2.5}, {2.5, 2.5}];
domain2[R_] := Disk[{0, 0}, R]
Table[RegionEqual[RegionIntersection[domain1, domain2[R]], 
  domain2[R]], {R, {1, 2, 3}}]

{True, True, False}

$\endgroup$

Your Answer

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

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