To visualize the interaction of sets, John Venn in 1880 thought to use overlapping circles, building on a similar idea used by Leonhard Euler in the 18th century. These illustrations now called Venn Diagrams.
Basic Venn diagrams can illustrate the interaction of two or three sets.
import numpy as np
import matplotlib.pyplot as plt
# EDIT: which of the 8 regions belongs to your expression?
NAME = "(H inter F) inter Wc" # the book's outlined region
region = lambda h, f, w: h and f and not w
# others to try:
# "H union F union W" lambda h, f, w: h or f or w
# "A union (B inter Cc)" style: lambda h, f, w: h or (f and not w)
# exactly one set: lambda h, f, w: (h + f + w) == 1
n = 500
x, y = np.meshgrid(np.linspace(-2.4, 2.4, n), np.linspace(-2.1, 2.4, n))
centres = [(-0.62, 0.42, "H"), (0.62, 0.42, "F"), (0.0, -0.62, "W")]
masks = [((x - cx) ** 2 + (y - cy) ** 2) <= 1.15 ** 2 for cx, cy, _ in centres]
shaded = np.vectorize(region)(*masks)
fig, ax = plt.subplots(figsize=(5.6, 5.4))
ax.imshow(shaded, extent=(-2.4, 2.4, -2.1, 2.4), origin="lower",
cmap="Greens", vmin=0, vmax=1.6, alpha=0.85, aspect="equal")
for cx, cy, lab in centres:
ax.add_patch(plt.Circle((cx, cy), 1.15, fill=False, lw=2, color="black"))
ax.text(cx * 1.75, cy * 1.75 + 0.25, lab, fontsize=15, ha="center")
ax.set_title(f"shaded region: {NAME}", fontsize=13)
ax.set_xticks([]); ax.set_yticks([])
plt.show()
print("the 8 regions of a three-circle diagram")
print(f"{'H':>3}{'F':>3}{'W':>3} region shaded?")
for h in (True, False):
for f in (True, False):
for w in (True, False):
names = [n for n, v in (("H", h), ("F", f), ("W", w)) if v]
desc = ("in all three" if len(names) == 3 else
" and ".join(names) + " only" if names else "outside all three")
mark = "SHADED" if region(h, f, w) else "-"
print(f"{str(h)[0]:>3}{str(f)[0]:>3}{str(w)[0]:>3} {desc:<30} {mark}")
Adapted from Math in Society by David Lippman, hosted on LibreTexts (math.libretexts.org) and licensed under CC BY-SA 3.0. Changes were made. License: CC-BY-SA-3.0.
These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or any other accessibility standard. Every page is built against an automated accessibility gate, and our target for the published editions is WCAG 2.2 Level AA. If something is unusable, please tell us.