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 complements

The complement

Explanation

Sometimes we need "not AA" - all elements that aren't in a set. To define this precisely, we first need a universal set UU containing all elements under consideration.

Complement

Definition

The complement of set AA, written AcA^c, contains all elements in UU that are not in AA. We write this as:

Ac=UAA^c = U \setminus A

To find AcA^c, we list every element from UU that doesn't appear in AA. If AA contains the even numbers, then AcA^c contains the odd numbers - every element that fails to satisfy the original condition.

On a Venn diagram, the complement AcA^c is the region outside circle AA but still inside the rectangle UU. Use the button below to toggle the shading.

U
A

The complement captures everything that's "left over" when we exclude AA from the universal set.

Key Point

To compute AcA^c: start with UU, remove every element that's in AA, and keep the rest.

Example

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

Find AcA^c.

Solution

The complement AcA^c contains all elements in UU that are not in AA. We check each element:

  • 11: not in AA, so 1Ac1 \in A^c
  • 22: in AA, so 2Ac2 \notin A^c
  • 33: not in AA, so 3Ac3 \in A^c
  • 44: in AA, so 4Ac4 \notin A^c
  • 55: not in AA, so 5Ac5 \in A^c
  • 66: in AA, so 6Ac6 \notin A^c
Ac={1,3,5}A^c = \{1, 3, 5\}

The complement contains the odd numbers - all elements not in the original set of even numbers.

Practice questions

4 questions

Let U={1,2,3,4,5}U = \{1, 2, 3, 4, 5\} and A={1,3,5}A = \{1, 3, 5\}.

What is AcA^c?

Select the correct answer:

+ 3 more questions

Properties of complements

Explanation

Complements have three fundamental properties that follow directly from their definition.

Property 1: Double complement

Taking the complement twice returns the original set:

(Ac)c=A(A^c)^c = A

If AA contains the even numbers and AcA^c contains the odd numbers, then (Ac)c(A^c)^c is "not odd" - which brings us back to even.

Property 2: Disjoint

A set and its complement share no elements:

AAc=A \cap A^c = \emptyset

No element can be both in AA and not in AA simultaneously. Sets with empty intersection are disjoint.

Property 3: Exhaustive coverage

A set and its complement together cover the entire universal set:

AAc=UA \cup A^c = U

Every element is either in AA or not in AA - there's no third option. Together, AA and AcA^c account for everything.

Key Point

Properties 2 and 3 together say that AA and AcA^c partition UU - they're disjoint (no overlap) and exhaustive (nothing left out).

Example

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

Verify all three complement properties for this set.

Solution

First, we find the complement:

Ac={2,4,6}A^c = \{2, 4, 6\}

Property 1: (Ac)c=A(A^c)^c = A

The complement of Ac={2,4,6}A^c = \{2, 4, 6\} contains all elements not in {2,4,6}\{2, 4, 6\}:

(Ac)c={1,3,5}=A(A^c)^c = \{1, 3, 5\} = A

Property 2: AAc=A \cap A^c = \emptyset

The intersection contains elements in both AA and AcA^c:

  • A={1,3,5}A = \{1, 3, 5\}
  • Ac={2,4,6}A^c = \{2, 4, 6\}

These sets share no elements:

AAc=A \cap A^c = \emptyset

Property 3: AAc=UA \cup A^c = U

The union contains all elements in either AA or AcA^c:

AAc={1,3,5}{2,4,6}={1,2,3,4,5,6}=UA \cup A^c = \{1, 3, 5\} \cup \{2, 4, 6\} = \{1, 2, 3, 4, 5, 6\} = U

Practice questions

4 questions

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

What is (Bc)c(B^c)^c?

Select the correct answer:

+ 3 more questions

De Morgan's laws

Explanation

When we take the complement of a union or intersection, something interesting happens. De Morgan's laws tell us exactly how complements interact with these operations.

De Morgan's laws

Definition

  1. (AB)c=AcBc(A \cup B)^c = A^c \cap B^c - "not (A or B)" equals "not A and not B"
  2. (AB)c=AcBc(A \cap B)^c = A^c \cup B^c - "not (A and B)" equals "not A or not B"

The first law says: to be outside "AA or BB", an element must be outside AA and outside BB. If it were in either one, it would be in the union.

The second law says: to be outside "AA and BB", an element just needs to be outside AA or outside BB. Being missing from either set is enough to be missing from their intersection.

Intuition

Optional

Use the interactive widget below to see why these laws work.

Select a law:

De Morgan's first law

Left-hand side

UAB

Right-hand side

UAB

Use Next to step through and see why both sides describe the same region.

Key Point

De Morgan's laws let us rewrite compound set expressions. This can simplify certain problems.

Example

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

  1. Find (AB)c(A \cup B)^c directly
  2. Find AcBcA^c \cap B^c and verify they match

Solution

Part 1: Finding (AB)c(A \cup B)^c directly

First, compute the union:

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

Now take the complement - elements in UU but not in ABA \cup B:

(AB)c={5}(A \cup B)^c = \{5\}

Part 2: Finding AcBcA^c \cap B^c

First, find each complement:

Ac={4,5,6}A^c = \{4, 5, 6\} Bc={1,3,5}B^c = \{1, 3, 5\}

Now take the intersection - elements in both AcA^c and BcB^c:

AcBc={5}A^c \cap B^c = \{5\}

Both methods give {5}\{5\}, confirming De Morgan's first law: (AB)c=AcBc(A \cup B)^c = A^c \cap B^c.

The element 55 is the only one that's in neither AA nor BB.

Practice questions

4 questions

Which expression is equivalent to (AB)c(A \cup B)^c?

Select the correct answer:

+ 3 more questions