Discrete Math for Data Science

DSCI 220, 2025 W1

October 1, 2025

Announcements

Modular Arithmetic

Goals

  • Read and use \(a\equiv b\pmod m\) as “\(m\) divides \(a-b\).”

  • Compute and reason with \(\bmod\) for \(+\), \(-\), \(\times\), and exponents.

  • Find/recognize modular inverses and solve a linear congruence.

  • Explore a 2-dial puzzle.

Warm Up

What’s the rightmost digit of \(7^{2025}\)?

 

 

 

 

05:00

Congruence \(\bmod m\)

 

Definition: \(a\equiv b\pmod m \iff m\mid(a-b)\).

 

Quick checks:

 

  • \(29\equiv \underline{~~~~~}\quad \pmod 7\)


  • \(-11\equiv \underline{~~~~~}\quad\pmod 6\)

Operators \(\bmod m\)

 

Work \(\bmod 7\):

 

  1. \((29+12)\bmod 7 \equiv \underline{~~~~~}\quad\bmod 7\)
  2. \((5\cdot 9)\bmod 7\equiv \underline{~~~~~}\quad\bmod 7\)
  3. \((4-18)\bmod 7\equiv \underline{~~~~~}\quad\bmod 7\)
  4. \(2^{5}\bmod 7\equiv \underline{~~~~~}\quad\bmod 7\)

 

What are the rules?

Modular Arithmetic

Definition: \(a \equiv b \pmod m \iff m \mid (a-b)\)

If \(a \equiv b \pmod m\) and \(c \equiv d \pmod m\), then:

  • Addition: \(a + c \equiv b + d \pmod m\)
  • Subtraction: \(a - c \equiv b - d \pmod m\)
  • Multiplication: \(ac \equiv bd \pmod m\)
  • Exponentiation: for any integer \(n \ge 0\), \(a^{n} \equiv b^{n} \pmod m\)

Reduce anytime: reduce intermediate results mod \(m\) at any step.

Caution (division): “Division” is only valid when a modular inverse exists.
\(\gcd(a,m)=1\Rightarrow a^{-1}\) exists, and \(ax \equiv b \pmod m \Rightarrow x \equiv a^{-1}b \pmod m\).

Caution (exponents): From \(a\equiv b \pmod m\) you may raise the bases: \(a^n\equiv b^n\), but in general \(c^{a}\not\equiv c^{b}\pmod m\).

Proof 1: Multiplication

Claim: If \(a\equiv b\pmod m\), and \(c\equiv d\pmod m\) then \(ac\equiv bd\pmod m\).

Proof:

Proof 2: Exponentiation

Claim: If \(a\equiv b\pmod m\), then for all \(n\ge1\), \(a^n\equiv b^n\pmod m\).

Proof: Consider arbitrary integers \(a\), \(b\), \(m\) so that \(a\equiv b\pmod m\), and an arbitrary integer \(n\ge1\).

(IH) Assume that for any \(j < n\), \(a^j\equiv b^j\pmod m\).

Case 1 \((n=1)\):

 

Case 2 \((n>1)\):

Discovery: Inverses \(\bmod\) a Prime

Task \(\pmod 7\): Fill this table and find inverses of \(1,2,3,4\).

\(\times\) \(1\) \(2\) \(3\) \(4\)
\(1\)
\(2\)
\(3\)
\(4\)

Then answer: \(1^{-1},\,2^{-1},\,3^{-1},\,4^{-1}\ \pmod 7\).

Linear Congruences

 

Solve:

  • \(9x\equiv 1\pmod{26}\)

 

 

  • \(9x\equiv 5\pmod{26}\)

Big Powers Fast

 

Pick one:

  • \(2^{1000}\pmod 7\)
  • \(3^{12345}\pmod{10}\)
  • \(5^{2024}\pmod{13}\)

Two Dials

Find \(x\pmod {15}\) such that
\(x\equiv 2\pmod 3\) and \(x\equiv 1\pmod 5\).

05:00