Free preview

82 lessons

Mathematical Foundations for ML

Free preview

Mathematical Foundations for ML · 82 lessons

Build the maths foundations that make ML click

No surprise gaps

Actually remember it

Skip what you know

One subscription. All learning paths included.

Our content is best on a larger screen

Set union and intersection

Set union

Explanation

Given two sets, we often want to combine them. The union collects elements from both.

Union of sets

Definition

The union of sets AA and BB, written ABA \cup B, contains all elements that are in AA, in BB, or in both.

To form a union, we collect every element from either set. When the same element appears in both sets, we list it just once - sets don't have duplicates.

'Or' includes 'both'

Gotcha

In mathematics, "AA or BB" always means "AA or BB or both". An element in both sets is still included in the union. This differs from everyday language, where "or" sometimes implies exclusivity.

Example

Let A={1,2,3}A = \{1, 2, 3\} and B={2,4,6}B = \{2, 4, 6\}. Find ABA \cup B.

Solution

The union ABA \cup B contains all elements that are in AA, in BB, or in both.

From AA: 1,2,31, 2, 3

From BB: 2,4,62, 4, 6

Combining these (noting that 22 appears in both, but we list it only once):

AB={1,2,3,4,6}A \cup B = \{1, 2, 3, 4, 6\}

Practice questions

4 questions

Let A={a,b}A = \{a, b\} and B={a,c}B = \{a, c\}.

What is ABA \cup B?

Select the correct answer:

+ 3 more questions

Set intersection

Explanation

Sometimes we want elements that satisfy both conditions simultaneously. This is the intersection.

Intersection of sets

Definition

The intersection of sets AA and BB, written ABA \cap B, contains only elements that are in both AA and BB.

The key word is "and". To form an intersection, we keep only elements that appear in both sets - everything else is excluded.

Key Point

When two sets have no elements in common, their intersection is the empty set \emptyset. We say the sets are disjoint - they share no elements.

For example, the set of odd integers and the set of even integers are disjoint - no integer is both odd and even, so their intersection is \emptyset.

Example

Let A={1,2,3}A = \{1, 2, 3\} and B={2,4,6}B = \{2, 4, 6\}.

Find ABA \cap B. Then let C={5,6}C = \{5, 6\} and find BCB \cap C.

Solution

Finding ABA \cap B:

The intersection contains only elements in both sets. Checking which elements of AA are also in BB:

  • 11: not in BB
  • 22: in BB
  • 33: not in BB
AB={2}A \cap B = \{2\}

Finding BCB \cap C:

Checking which elements of B={2,4,6}B = \{2, 4, 6\} are also in C={5,6}C = \{5, 6\}:

  • 22: not in CC
  • 44: not in CC
  • 66: in CC
BC={6}B \cap C = \{6\}

Practice questions

4 questions

Let A={a,b}A = \{a, b\} and B={a,c}B = \{a, c\}.

What is ABA \cap B?

Select the correct answer:

+ 3 more questions

Venn diagrams

Explanation

A Venn diagram is a visual way to represent sets and their relationships. The outer rectangle represents all elements under consideration - we label it UU. Sets are drawn as overlapping circles inside.

The overlapping circles create four distinct regions:

  • AA only (left crescent): elements in AA but not BB
  • BB only (right crescent): elements in BB but not AA
  • Overlap (ABA \cap B): elements in both sets
  • Outside both: elements in neither set

Each element belongs to exactly one region. Use the buttons below to see how the union and intersection appear on a Venn diagram.

U
A
B
A only
AB
B only
Neither A nor B

The union ABA \cup B covers all three inner regions (both circles). The intersection ABA \cap B covers only the overlap.

Example

Draw a Venn diagram for U={1,2,3,4,5,6}U = \{1, 2, 3, 4, 5, 6\} with A={1,2,3}A = \{1, 2, 3\} and B={2,4,6}B = \{2, 4, 6\}. Place each element in the correct region. Identify ABA \cup B and ABA \cap B from the diagram.

Solution

First, we classify each element by which sets it belongs to:

  • 11: in AA only
  • 22: in both AA and BB
  • 33: in AA only
  • 44: in BB only
  • 55: in neither
  • 66: in BB only
U
A
B
1
2
3
4
5
6

Reading from the diagram:

Union ABA \cup B: all elements inside either circle - {1,2,3,4,6}\{1, 2, 3, 4, 6\}

Intersection ABA \cap B: only the element in the overlap - {2}\{2\}

Practice questions

4 questions

The Venn diagram below shows sets AA and BB with U={1,2,3,4,5}U = \{1, 2, 3, 4, 5\}.

U
A
B
1
2
3
4
5

What is ABA \cup B?

Select the correct answer:

+ 3 more questions