Files
uni_notes/Studium/DAS/Arithmetic.md
2026-04-07 11:36:49 +02:00

2.1 KiB

Asymptotic Equivalence Classes (Big-O)

The equivalence relation definition given in the task is asking you to find functions that grow at the exact same rate (also known as Big-Theta \Theta):

f asymp g <==> f in O(g) and g in O(f)

Notation of f in O(g) means "function f doesn't grow faster than $g$"

The "Dominant Term" Rule

To find which class a function belongs to, simplify it to its core growth rate:

  1. Drop all lower-order terms: In n^3 + n^2, drop the n^2.
  2. Drop all constant multipliers: 5n^2 and 1000n^2 both become just n^2.
  3. Identify the highest rank: Factorials (n!) > Exponentials (2^n, e^n) > Polynomials (n^3, n^2) > Linear (n) > Logarithmic (log n) > Constant (1).

Euclidian Algorithm

Purpose is to find the GCD (Greatest Common Divisor).

Core Rule

Fill out this formula:

"Dividend" = ("Quotient" * "Divisor") + "Remainder"
  1. Divide the bigger number by the smaller one
  2. How many times does it fit -> "Quotient"
  3. Find out whats leftover -> "Remainder"
  4. Shift to left and repeat ("Old Divisor" -> "Dividend", "Remainder" -> "Divisor")

Result is the last "Remainder" that is not 0.

Bezout Coefficients

Goal: find a x and y so that "Divident" * x + "Divisor" * y = gcd("Dividend", "Divisor")

  1. Rewrite Euclid (above) equations to solve for remainder ("Remainder" = "Old Remainder" - "Dividend" * "Divisor")
  2. Substitute remainders
  3. Simplify (Final Form: "GCD" = x * "Dividend" + "y * Divisor")

Extended Euclidian Algorithm

Only valid for GCD = 1

  1. Find GCD using Euclidian Algorithm

    1. A = q_1 * B + r_1
    2. B = q_2 * r_1 + r_2
    3. r_1 = q_3 * r_2 + 1
  2. Unwrap

    1. 1 = r_1 - (q_3 * r_2) mit r_2 = B - q_2 * r_1
    2. 1 = r_1 - (q_3 * (B - q_2 * r_1)) mit q_3 ausmultiplizieren
    3. 1 = (1 + q_3 * q_2) * r_1 - q_3 * B mit r_1 = A - q_1 * B
    4. 1 = (1 + q_3 * q_2) * (A - q_1 * B) - q_3 * B
  3. Simplify to x * A + y * B

  4. Coefficient of A is the modular inverse

Totient function

Denoted by phi(n) = n (1 - 1/p_1)(1 - 1/p_2)...(1-1/p_k) where p_i is a prime factor of n.