Back
In print settings: Save as PDF, turn headers and footers off, turn background graphics on.

Mathematical Foundations

Logic, sets, and the axiomatic basis of mathematics.

Official Documentation

July 2026

Contents

Overview

  • Algebraic Numbers
  • Axiomatic Systems
  • Cardinality and Infinite Sets
  • Category Theory
  • Chaos Theory and Fractals
  • Complex Numbers
  • Diophantine Equations
  • Distributions and Generalized Functions
  • Divisibility and Congruence
  • Dynamical Systems
  • Mathematics - Recap and Future Directions
  • Homological Algebra
  • The Nature of Mathematics
  • Advanced Logic
  • Gödel's Incompleteness
  • Propositional Logic
  • Mathematical Notation and Logic
  • Number Theory
  • Number Systems and Arithmetic
  • Numerical Root Finding
  • Predicate Logic
  • Prime Number Distribution
  • Projective Geometry
  • Proof Techniques
  • Real Numbers and Continuity
  • RSA Encryption

Overview

Section Detail

Algebraic Numbers

Algebraic Numbers

Algebraic numbers are complex numbers that are roots of non-zero polynomials with rational coefficients.

Definition and Minimal Polynomials

A number αC\alpha \in \mathbb{C} is algebraic if there exists a polynomial P(x)Q[x]P(x) \in \mathbb{Q}[x] such that P(α)=0P(\alpha) = 0. The unique monic polynomial of lowest degree that α\alpha satisfies is called its minimal polynomial.

python
1def evaluate_rational_poly(coeffs, x):
2 res = 0
3 for i, c in enumerate(coeffs):
4 res += c * (x**i)
5 return res
6 
7# Check if i (sqrt(-1)) is algebraic
8# Minimal poly: x^2 + 1
9coeffs_i = [1, 0, 1]
10import math
11val = evaluate_rational_poly(coeffs_i, 1j)
12print(f"p(i) = {val}")
13 
14# Check if sqrt(2) + sqrt(3) is algebraic
15# It satisfies x^4 - 10x^2 + 1 = 0
16alpha = math.sqrt(2) + math.sqrt(3)
17coeffs_alpha = [1, 0, -10, 0, 1]
18print(f"p(sqrt(2)+sqrt(3)) = {evaluate_rational_poly(coeffs_alpha, alpha)}")

Algebraic Integers

An algebraic integer is a root of a monic polynomial with integer coefficients. For example, 2\sqrt{2} is an algebraic integer, but 1/21/2 is not (it is an algebraic number, but its minimal polynomial is 2x12x - 1, which is not monic).

Is every rational number an algebraic number?

Transcendental Numbers

Numbers that are not algebraic are called transcendental. Proving a number is transcendental is usually much harder. Famous examples include π\pi and ee.

python
1import math
2 
3# Liouville's constant is transcendental
4liouville = sum(10**(-math.factorial(n)) for n in range(1, 10))
5print(f"Liouville's constant approx: {liouville}")
6print("Transcendental numbers are 'uncountably' more common than algebraic ones.")

What is the minimal polynomial of the golden ratio phi = (1 + sqrt(5))/2?

Section Detail

Axiomatic Systems

Axiomatic Systems

Mathematics is not built on thin air; it is built on Axioms. An axiom is a statement that is taken to be true, to serve as a premise or starting point for further reasoning.

1. ZFC: The Foundation of Set Theory

Almost all modern mathematics is built on Zermeio-Fraenkel Set Theory (ZFC). Think of these as the “low-level assembly instructions” of math.

The Axiom of Extensionality

Two sets are equal if they have the same elements.

  • Example: {1,2}\{1, 2\} is the same as {2,1}\{2, 1\}. The order and repetition don’t matter.
  • Code Analogy: In Python, a set behaves exactly like this.
python
1# Demonstrating Extensionality
2set_a = {1, 2, 3}
3set_b = {3, 2, 1, 1, 2}
4 
5print(f"Set A: {set_a}")
6print(f"Set B: {set_b}")
7print(f"Are they equal? {set_a == set_b}")
8 

The Axiom of Infinity

There exists an infinite set. Without this, we couldn’t formally prove that the set of Natural Numbers (N\mathbb{N}) exists in its entirety. It allows us to build the infinite sequence {0,1,2,}\{0, 1, 2, \dots\}.

The Axiom of Choice (the C in ZFC)

If you have a collection of bins, you can choose one item from each bin. This seems obvious, but for infinitely many bins, it leads to strange results like the Banach-Tarski Paradox, where you can disassemble a sphere and reassemble it into two identical spheres.

2. Russell’s Paradox

Before ZFC, mathematicians used “Naive Set Theory.” Bertrand Russell showed this was broken with a simple logical trap:

Consider the set SS of all sets that do not contain themselves. Does SS contain itself?

python
1# The Logic of Russell's Paradox
2def check_membership(contains_self):
3 # Definition of S: x is in S if x does NOT contain itself.
4 # If we check if S is in S:
5 return not contains_self
6 
7# There is no stable answer!
8print(f"If we assume True -> {check_membership(True)}")
9print(f"If we assume False -> {check_membership(False)}")
10 

ZFC fixes this by making it impossible to define “the set of all sets.” You can only create sub-sets of existing sets (the Axiom of Specification).

3. Why Formalize?

We formalize mathematics to ensure that our proofs are not just “convincing” but mechanically certain. If our foundational axioms have a contradiction, everything we build on top of them (calculus, physics, computer science) would collapse.

Exercises

Why did ZFC replace Naive Set Theory?

Which Axiom states that {1, 2} and {2, 1} are the same set?

Section Detail

Cardinality and Infinite Sets

Cardinality and Infinite Sets

Cardinality is a measure of the “number of elements” of a set. For finite sets, this is just a natural number, but for infinite sets, things become more complex.

Equinumerosity

Two sets AA and BB have the same cardinality, A=B|A| = |B|, if there exists a bijection f:ABf: A \to B.

A set is countably infinite if it has the same cardinality as the natural numbers N\mathbb{N}. Surprisingly, the set of rational numbers Q\mathbb{Q} is countable, while the set of real numbers R\mathbb{R} is not.

python
1def count_to_infinity(limit):
2 # Demonstrating that Even numbers are equinumerous to Natural numbers
3 # f(n) = 2n
4 evens = [(n, 2*n) for n in range(limit)]
5 return evens
6 
7print("Mapping N to Evens (First 5):")
8for pair in count_to_infinity(5):
9 print(f"n={pair[0]} maps to even={pair[1]}")

Cantor’s Diagonal Argument

Georg Cantor proved that the cardinality of the real numbers (the Continuum, c\mathfrak{c}) is strictly greater than the cardinality of the natural numbers (0\aleph_0). He used a technique called diagonalization.

python
1import random
2 
3def cantors_diagonal(rows):
4 """Given a list of decimal expansions, create a number that isn't in the list."""
5 new_number = "0."
6 for i in range(len(rows)):
7 # Take the i-th digit of the i-th row and change it
8 digit = int(rows[i][i+2]) # offset for "0."
9 new_digit = (digit + 1) % 10
10 new_number += str(new_digit)
11 return new_number
12 
13sequences = ["0.12345", "0.55555", "0.98765", "0.11111", "0.00000"]
14print(f"Generated number not in list: {cantors_diagonal(sequences)}")

What is the result of the union of two countably infinite sets?

Cantor’s Theorem

Cantor’s Theorem states that for any set AA, the cardinality of its power set P(A)\mathcal{P}(A) is strictly greater than the cardinality of AA: A<P(A)|A| < |\mathcal{P}(A)| This results in an infinite hierarchy of infinities: 0,1,2,\aleph_0, \aleph_1, \aleph_2, \dots

Does there exist a set with cardinality between integers and real numbers?

Section Detail

Category Theory

Category Theory

Category theory formalizes mathematical structure and its concepts in terms of a collection of objects and arrows (morphisms).

Categories and Morphisms

A category C\mathcal{C} consists of:

  • A class ob(C)ob(\mathcal{C}) of objects.
  • A class hom(C)hom(\mathcal{C}) of morphisms (arrows) between objects.
  • A composition law \circ that is associative and has identity morphisms.

Examples include Set (sets and functions), Grp (groups and homomorphisms), and Top (topological spaces and continuous maps).

python
1class Category:
2 def __init__(self, name):
3 self.name = name
4 self.objects = set()
5 self.morphisms = {} # (A, B) -> list of f
6 
7 def add_object(self, obj):
8 self.objects.add(obj)
9 
10 def add_morphism(self, source, target, name):
11 if (source, target) not in self.morphisms:
12 self.morphisms[(source, target)] = []
13 self.morphisms[(source, target)].append(name)
14 
15# Modeling a simple Finite Category
16C = Category("SimpleFinite")
17C.add_object("A")
18C.add_object("B")
19C.add_morphism("A", "B", "f")
20C.add_morphism("B", "B", "id_B")
21 
22print(f"Objects in {C.name}: {C.objects}")
23print(f"Morphisms: {C.morphisms}")

Functors

A Functor F:CDF: \mathcal{C} \to \mathcal{D} is a mapping that preserves the category structure:

  1. It maps objects in C\mathcal{C} to objects in D\mathcal{D}.
  2. It maps morphisms f:ABf: A \to B in C\mathcal{C} to morphisms F(f):F(A)F(B)F(f): F(A) \to F(B) in D\mathcal{D}.
  3. It preserves identity and composition.

What is a 'covariant' functor?

Natural Transformations

A natural transformation provides a way of transforming one functor into another while respecting the internal structure of the categories involved. It is often described as a “morphism between functors.”

In the category Set, what is the 'Initial Object'?

Yoneda Lemma

The Yoneda Lemma suggests that an object is entirely determined by its relationships (morphisms) with other objects in the category. This is a foundational result that allows one to embed any category into a category of functors.

Section Detail

Chaos Theory and Fractals

Chaos Theory and Fractals

Chaos theory explores systems that are highly sensitive to initial conditions—a concept popularly known as the “Butterfly Effect.” Fractals are complex geometric shapes that exhibit self-similarity across different scales.

Sensitive Dependence on Initial Conditions

In a chaotic system, small differences in initial state lead to vastly different outcomes over time. This makes long-term prediction impossible, even for deterministic systems.

python
1def logistic_map(x, r):
2 return r * x * (1 - x)
3 
4r = 3.9 # Chaotic regime
5x1 = 0.5
6x2 = 0.500001
7dt = []
8 
9print("Comparison of two nearly identical starting points:")
10for i in range(10):
11 x1 = logistic_map(x1, r)
12 x2 = logistic_map(x2, r)
13 print(f"Iteration {i}: x1={x1:.4f}, x2={x2:.4f}, diff={abs(x1-x2):.6f}")

Bifurcation

As a system parameter (like rr in the logistic map) changes, the qualitative behavior of the system can change abruptly at certain values, called bifurcation points.

What happens to the logistic map as 'r' increase from 2.5 to 3.5?

Fractals and Hausdorff Dimension

Fractals are objects with non-integer dimensions. The Hausdorff dimension measures how a set fills space as it is scaled. For the Cantor set or the Koch snowflake, this dimension is a fraction.

python
1import numpy as np
2 
3def mandelbrot(c, max_iter=100):
4 z = 0
5 for n in range(max_iter):
6 if abs(z) > 2:
7 return n
8 z = z*z + c
9 return max_iter
10 
11# Testing a few points
12points = [complex(0, 0), complex(1, 1), complex(-1, 0)]
13for p in points:
14 res = mandelbrot(p)
15 status = "Inside" if res == 100 else f"Escaped at iter {res}"
16 print(f"Point {p}: {status}")

What is the defining property of the Mandelbrot set?

Strange Attractors

A strange attractor is an attractor that exhibits chaotic behavior. The most famous example is the Lorenz Attractor, which arises from a simplified model of atmospheric convection.

Section Detail

Complex Numbers

Complex Numbers

Complex numbers expand the real number system by introducing the imaginary unit ii, where i2=1i^2 = -1.

Arithmetic in the Complex Plane

A complex number zz is written as x+iyx + iy, where xx is the real part and yy is the imaginary part. Addition and multiplication follow standard algebraic rules, with i2=1i^2 = -1.

python
1# Python supports complex numbers natively using 'j'
2z1 = 3 + 4j
3z2 = 1 - 2j
4 
5# Addition
6print(f"z1 + z2 = {z1 + z2}")
7 
8# Multiplication (3+4j)*(1-2j) = 3 - 6j + 4j - 8j^2 = 3 - 2j + 8 = 11 - 2j
9print(f"z1 * z2 = {z1 * z2}")
10 
11# Magnitude (Absolute Value)
12print(f"|z1| = {abs(z1)}")

Polar Form and Euler’s Formula

Complex numbers can be represented in polar coordinates (r,θ)(r, \theta). Euler’s Formula connects the exponential function to trigonometry: eiθ=cosθ+isinθe^{i\theta} = \cos \theta + i \sin \theta Thus, z=reiθz = r e^{i\theta}.

python
1import cmath
2import math
3 
4z = 1 + 1j
5r, theta = cmath.polar(z)
6print(f"r: {r:.3f}, theta: {theta:.3f} rad")
7 
8# Euler's Identity: e^(i*pi) + 1 = 0
9identity = cmath.exp(1j * math.pi) + 1
10print(f"e^(i*pi) + 1 = {identity.real:.1f} + {identity.imag:.1f}j")

Fundamental Theorem of Algebra

The Fundamental Theorem of Algebra states that every non-constant polynomial of degree nn with complex coefficients has exactly nn complex roots (counting multiplicity).

What is the result of (1 + i)^2?

Which identity is known as Euler's Identity?

Section Detail

Diophantine Equations

Diophantine Equations

Diophantine equations are polynomial equations for which only integer or rational solutions are sought.

Linear Diophantine Equations

A linear Diophantine equation has the form ax+by=cax + by = c. This has integer solutions if and only if gcd(a,b)\gcd(a, b) divides cc.

python
1def extended_gcd(a, b):
2 if a == 0: return b, 0, 1
3 gcd, x1, y1 = extended_gcd(b % a, a)
4 x = y1 - (b // a) * x1
5 y = x1
6 return gcd, x, y
7 
8def solve_linear_diophantine(a, b, c):
9 gcd, x0, y0 = extended_gcd(a, b)
10 if c % gcd != 0:
11 return None, "No solution"
12 m = c // gcd
13 return (x0 * m, y0 * m), f"gcd({a}, {b}) = {gcd}"
14 
15# Solve 12x + 15y = 9
16print(f"Solution to 12x + 15y = 9: {solve_linear_diophantine(12, 15, 9)}")
17# Solve 12x + 15y = 10
18print(f"Solution to 12x + 15y = 10: {solve_linear_diophantine(12, 15, 10)}")

Pythagorean Triples

The equation x2+y2=z2x^2 + y^2 = z^2 is one of the most famous Diophantine equations. Primitive solutions can be generated using Euclid’s formula: x=m2n2,y=2mn,z=m2+n2x = m^2 - n^2, y = 2mn, z = m^2 + n^2 for m>n>0m > n > 0.

python
1def generate_pythagorean_triples(limit):
2 triples = []
3 for m in range(2, int(limit**0.5) + 2):
4 for n in range(1, m):
5 x = m**2 - n**2
6 y = 2 * m * n
7 z = m**2 + n**2
8 if z <= limit:
9 triples.append((x, y, z))
10 return triples
11 
12print(f"Triples up to 30: {generate_pythagorean_triples(30)}")

Fermat’s Last Theorem

Fermat’s Last Theorem states that xn+yn=znx^n + y^n = z^n has no positive integer solutions for n>2n > 2. This was conjectured by Pierre de Fermat in 1637 and finally proven by Andrew Wiles in 1994 using the theory of modular forms.

When does ax + by = c have integer solutions?

Elliptic Curves

Diophantine equations of the form y2=x3+ax+by^2 = x^3 + ax + b are known as Elliptic Curves. They have profound applications in modern cryptography and were crucial in the proof of Fermat’s Last Theorem.

Which n > 2 allows for x^n + y^n = z^n in positive integers?

Section Detail

Distributions and Generalized Functions

Distributions and Generalized Functions

In many physical applications, we encounter objects like the Dirac delta function that are not “functions” in the classical sense. Distribution theory provides a rigorous mathematical framework for these entities.

The Problem with Classical Functions

A classical function f:RRf: \mathbb{R} \to \mathbb{R} has a value at every point. However, an idealized point mass or a sudden impulse has a “value” of infinity at a point and zero elsewhere, yet its integral is finite.

Distributions as Linear Functionals

A distribution TT is a continuous linear functional on the space of test functions DD (smooth functions with compact support). We denote the action of a distribution TT on a test function ϕ\phi as T,ϕ\langle T, \phi \rangle.

The Dirac Delta Distribution

The Dirac delta δ\delta is defined by its effect under an integral (or pairing): δ,ϕ=ϕ(0)\langle \delta, \phi \rangle = \phi(0) For any test function ϕ\phi.

python
1import numpy as np
2 
3def gaussian_approximation(x, epsilon):
4 """The Dirac delta can be viewed as the limit of a zero-centered Gaussian."""
5 return (1.0 / (epsilon * np.sqrt(np.pi))) * np.exp(-(x/epsilon)**2)
6 
7x_vals = np.linspace(-1, 1, 100)
8# As epsilon -> 0, the peak gets higher and narrower
9peak_01 = gaussian_approximation(0, 0.1)
10peak_001 = gaussian_approximation(0, 0.01)
11 
12print(f"Peak with epsilon=0.1: {peak_01:.2f}")
13print(f"Peak with epsilon=0.01: {peak_001:.2f}")
14print("The area under these curves is always 1.")

What is the derivative of the Heaviside step function H(x) in the sense of distributions?

Weak Derivatives

Distribution theory allows us to define the derivative of any locally integrable function. If ff is a distribution, its weak derivative ff' is defined by: f,ϕ=f,ϕ\langle f', \phi \rangle = -\langle f, \phi' \rangle This formula is inspired by the integration by parts formula where boundary terms vanish for test functions.

Why is the space of test functions required to have compact support?

Sobolev Spaces

Sobolev spaces are spaces of functions whose weak derivatives exist and belong to LpL^p spaces. They are essential in the study of partial differential equations.

Section Detail

Divisibility and Congruence

Divisibility and Congruence

Divisibility is the fundamental relation of number theory. We say aa divides bb (aba \mid b) if there exists an integer kk such that b=akb = ak.

1. The Division Algorithm

For any integers aa and bb (with b>0b > 0), there exist unique integers qq (quotient) and rr (remainder) such that: a=bq+r,0r<ba = bq + r, \quad 0 \le r < b

python
1def division_demo(a, b):
2 q = a // b
3 r = a % b
4 print(f"{a} = {b} * {q} + {r}")
5 return q, r
6 
7division_demo(103, 7)

2. Congruence Relations

Gauss introduced the notation ab(modn)a \equiv b \pmod{n} to signify that aa and bb have the same remainder when divided by nn. This is an equivalence relation, meaning it is reflexive, symmetric, and transitive.

Properties of Congruence:

  1. If aba \equiv b and cdc \equiv d, then a+cb+d(modn)a + c \equiv b + d \pmod{n}.
  2. If aba \equiv b and cdc \equiv d, then acbd(modn)ac \equiv bd \pmod{n}.
  3. akbk(modn)a^k \equiv b^k \pmod{n} for any k0k \ge 0.

If x ≡ 3 (mod 7), what is x^2 mod 7?

3. Fast Modular Exponentiation

In cryptography, we often calculate abmodna^b \bmod n where bb is a massive number. We use the “Square and Multiply” algorithm to do this in logarithmic time.

python
1def fast_pow(base, power, mod):
2 result = 1
3 while power > 0:
4 if power % 2 == 1:
5 result = (result * base) % mod
6 base = (base * base) % mod
7 power //= 2
8 return result
9 
10# Calculate 7^100 mod 13
11print(f"7^100 mod 13: {fast_pow(7, 100, 13)}")
12# Compare with Python's built-in pow()
13print(f"Verify with pow(7, 100, 13): {pow(7, 100, 13)}")

4. Fermat’s Little Theorem

If pp is prime and aa is not divisible by pp, then ap11(modp)a^{p-1} \equiv 1 \pmod{p}. This provides a fast way to check if a number is probably prime (the Fermat Primality Test).

Using Fermat's Little Theorem, what is 2^10 mod 11?

5. Summary Check

If a ≡ b (mod n), what can we say about (a - b)?

Section Detail

Dynamical Systems

Dynamical Systems

A Dynamical System is a triplet (T,M,Φ)(T, M, \Phi) where TT is the time domain, MM is the Phase Space (manifold of possible states), and Φ:T×MM\Phi: T \times M \to M is an evolution function satisfying:

  1. Φ(0,x)=x\Phi(0, x) = x (Identity)
  2. Φ(t,Φ(s,x))=Φ(t+s,x)\Phi(t, \Phi(s, x)) = \Phi(t+s, x) (Group property)

Discrete Dynamics: Iterated Maps

In a discrete system, the state is updated by a map f:MMf: M \to M: xn+1=f(xn)x_{n+1} = f(x_n)

The sequence {xn}n=0\{x_n\}_{n=0}^\infty is called the Orbit of x0x_0.

python
1def logistic_map(x, r):
2 return r * x * (1 - x)
3 
4def iterate(f, x0, n):
5 curr = x0
6 for _ in range(n):
7 curr = f(curr)
8 return curr
9 
10# Test logistic map at r=2.5 (Stable fixed point)
11r = 2.5
12f = lambda x: logistic_map(x, r)
13print(f"Iteration 10: {iterate(f, 0.5, 10):.3f}")
14print(f"Iteration 50: {iterate(f, 0.5, 50):.3f}")
15print("At r=2.5, the system settles to a single point.")

Fixed Points and Stability

A fixed point xx^* satisfies f(x)=xf(x^*) = x^*.

  • A point is Lyapunov Stable if for every ϵ>0\epsilon > 0, there exists δ>0\delta > 0 such that d(x0,x)<δ    d(xn,x)<ϵd(x_0, x^*) < \delta \implies d(x_n, x^*) < \epsilon for all n>0n > 0.
  • For a differentiable map f:RRf: \mathbb{R} \to \mathbb{R}, xx^* is Asymptotically Stable if f(x)<1|f'(x^*)| < 1.
python
1def check_stability(f_prime, x_star):
2 derivative_val = f_prime(x_star)
3 is_stable = abs(derivative_val) < 1
4 return is_stable, derivative_val
5 
6# For logistic map, f'(x) = r(1 - 2x)
7# Fixed point x* = 1 - 1/r
8r = 3.2
9x_star = 1 - 1/r
10f_prime = lambda x: r * (1 - 2 * x)
11 
12print(f"Is fixed point stable at r=3.2? {check_stability(f_prime, x_star)}")
13print("At r=3.2, |f'(x*)| > 1, so the fixed point is unstable (leads to limit cycles).")

Continuous Dynamics: Flow

Continuous systems are defined by a vector field V:MTM\mathbf{V}: M \to TM and an autonomous differential equation: x˙=dxdt=f(x)\dot{\mathbf{x}} = \frac{d\mathbf{x}}{dt} = \mathbf{f}(\mathbf{x})

The solution through x0x_0 is the Integral Curve or Flow Line. Stability is determined by the eigenvalues of the Jacobian Matrix J=fJ = \nabla \mathbf{f}. If all eigenvalues have negative real parts, the equilibrium is stable.

If a fixed point x* has |f'(x*)| = 0.5, is it stable?

What is a 'Chaos' state in a dynamical system characterized by?

Section Detail

Mathematics - Recap and Future Directions

Mathematics: Recap and Future Directions

We have traveled from the building blocks of set theory and logic, through the structures of algebra and the continuity of calculus, to the advanced landscapes of topology and manifolds.

The Unity of Mathematics

Mathematics is not a collection of isolated subjects but a deeply interconnected web. The tools you learned in linear algebra are used to solve differential equations, which in turn describe the curvature of manifolds in topology.

python
1import numpy as np
2 
3# A final synthesis: Linear Algebra + Numerical Methods
4def solve_system(A, b):
5 """Solving a linear system is the core of most applied mathematics."""
6 return np.linalg.solve(A, b)
7 
8A = np.array([[3, 1], [1, 2]])
9b = np.array([9, 8])
10sol = solve_system(A, b)
11print(f"System Solution: {sol}")

Unsolved Problems

Despite centuries of progress, many fundamental questions remain unanswered. Solving any of these would revolutionize our understanding of the universe:

  • The Riemann Hypothesis: Concerning the distribution of prime numbers.
  • P vs NP: Whether every problem whose solution can be quickly verified can also be quickly solved.
  • Navier-Stokes Existence and Smoothness: Describing the motion of fluid flow.

Which unsolved problem is central to cryptography and computer science?

Continuing the Journey

Mathematics is a creative endeavor. The skills of abstraction, logical deduction, and problem-solving you’ve developed are applicable far beyond the textbook. Whether you pursue theoretical research or apply these principles in engineering, finance, or data science, the language of mathematics will remain your most powerful tool.

python
1# Final challenge: Can you write a function for your favorite math concept?
2print("Success. Mathematics is an open field for exploration.")

What is the ultimate goal of mathematical inquiry?

Section Detail

Homological Algebra

Homological Algebra

Homological algebra is the branch of mathematics that studies homology in a general algebraic setting. It is a powerful tool used in algebraic topology, algebraic geometry, and number theory.

Chain Complexes

A chain complex (C,d)(C_\bullet, d_\bullet) is a sequence of abelian groups (or modules) and homomorphisms: dn+1CndnCn1dn1\dots \xrightarrow{d_{n+1}} C_n \xrightarrow{d_n} C_{n-1} \xrightarrow{d_{n-1}} \dots such that the composition of any two consecutive maps is zero: dndn+1=0d_n \circ d_{n+1} = 0.

This condition implies that the image of dn+1d_{n+1} is contained in the kernel of dnd_n: im(dn+1)ker(dn)im(d_{n+1}) \subseteq ker(d_n).

python
1import numpy as np
2 
3def is_chain_complex(matrices):
4 """Check if a sequence of boundary matrices forms a chain complex."""
5 for i in range(len(matrices) - 1):
6 # Result of d_n * d_{n+1} should be zero matrix
7 prod = np.matmul(matrices[i], matrices[i+1])
8 if not np.allclose(prod, 0):
9 return False, i
10 return True, None
11 
12# Example: d1 * d2 = 0
13d1 = np.array([[1, -1, 0], [0, 1, -1]]) # Edges to vertices
14d2 = np.array([[1], [1], [1]]) # Triangle face to edges
15 
16is_valid, index = is_chain_complex([d1, d2])
17print(f"Is chain complex: {is_valid}")

Homology Groups

The nn-th homology group is the quotient group: Hn(C)=ker(dn)im(dn+1)H_n(C) = \frac{ker(d_n)}{im(d_{n+1})} Elements of ker(dn)ker(d_n) are called cycles, and elements of im(dn+1)im(d_{n+1}) are called boundaries. Homology measures the extent to which the complex is not “exact.”

If a chain complex is 'exact' at position n, what is Hn?

Exact Sequences

A sequence is exact if the image of each map is exactly the kernel of the next. A short exact sequence is a sequence of the form: 0AfBgC00 \to A \xrightarrow{f} B \xrightarrow{g} C \to 0 which implies that ff is injective, gg is surjective, and im(f)=ker(g)im(f) = ker(g).

In a short exact sequence of finite-dimensional vector spaces, what is the relationship between their dimensions?

Diagram Chasing and the Snake Lemma

Diagram chasing is a method of proof used in homological algebra to establish properties of morphisms by tracing elements through commutative diagrams. The Snake Lemma is a fundamental result that relates the kernels and cokernels of two morphisms between short exact sequences.

Section Detail

The Nature of Mathematics

The Nature of Mathematics

Mathematics is the science of structure, order, and relation that has evolved from elemental practices of counting, measuring, and describing the shapes of objects. It deals with logical reasoning and quantitative calculation.

Abstraction

The power of mathematics lies in its ability to abstract. By stripping away the specific details of a problem, we can find universal patterns that apply to many different situations. For example, the number “3” is an abstraction that represents the commonality between 3 apples, 3 planets, and 3 ideas.

python
1def count_elements(iterable):
2 """Abstraction: Counting works the same way regardless of what we count."""
3 count = 0
4 for _ in iterable:
5 count += 1
6 return count
7 
8apples = ["fuji", "gala", "granny smith"]
9planets = ["Mercury", "Venus", "Earth"]
10 
11print(f"Apples: {count_elements(apples)}")
12print(f"Planets: {count_elements(planets)}")

Formalism and Proof

Mathematics is not just about calculation; it is about rigorous proof. A mathematical truth is one that follows logically from a set of starting assumptions (axioms). Once a theorem is proven, it remains true forever.

What is an 'axiom' in mathematics?

Applied Mathematics

While pure mathematics focuses on the intrinsic properties of mathematical structures, applied mathematics uses these structures to model the world around us—from the motion of stars to the behavior of financial markets.

python
1import numpy as np
2 
3def simple_growth_model(initial_pop, growth_rate, time):
4 """Mathematical model of exponential growth."""
5 return initial_pop * (1 + growth_rate)**time
6 
7print(f"Population after 10 years (5% growth): {simple_growth_model(100, 0.05, 10):.2f}")

Mathematics is often called the 'language' of what field?

Section Detail

Advanced Logic

Advanced Logic

Once we have the rules of deduction, we must ask ourselves about the power and reliability of the system itself. This is the domain of Meta-logic.

Soundness and Completeness

  • Soundness: A logic system is sound if everything that can be proved is actually true. If you can derive QQ from PP, then P    QP \implies Q is a tautology.
  • Completeness: A logic system is complete if everything that is true can be proved. If P    QP \implies Q is a tautology, there exists a sequence of steps to derive QQ from PP.

Propositional logic is both sound and complete. This means the “mechanical” process of manipulation perfectly matches the “semantic” truth of the universe.

Model Theory

Model theory studies the relationship between formal languages and their interpretations. A Model is a mathematical structure that makes the statements of a theory true.

If a set of statements has at least one model, it is Satisfiable. If it is true in all models, it is Valid.

Let’s use Python to check if a simple set of constraints is satisfiable (the SAT problem).

python
1# A primitive SAT Solver
2# We want to find A, B such that:
3# (A OR B) AND (NOT A OR B) AND (A OR NOT B)
4 
5def check_constraints(A, B):
6 c1 = A or B
7 c2 = (not A) or B
8 c3 = A or (not B)
9 return c1 and c2 and c3
10 
11# Brute force all possibilities
12possibilities = [(False, False), (False, True), (True, False), (True, True)]
13solutions = [p for p in possibilities if check_constraints(p[0], p[1])]
14 
15print(f"Combinations: {possibilities}")
16print(f"Valid Solutions (A, B): {solutions}")
17 

In computer science, solving this efficiently (PP vs NPNP) is one of the most important open questions in mathematics.

Exercises

If a logical system is Sound, what does that guarantee?

What is a 'Model' in advanced logic?

Section Detail

Gödel's Incompleteness

Gödel’s Incompleteness

In 1900, David Hilbert challenged the world to find a complete and consistent set of axioms for all of mathematics. He wanted a “Master Algorithm” that could prove or disprove any statement. In 1931, Kurt Gödel proved this dream was impossible.

1. The First Theorem: Truth vs. Provability

Gödel showed that in any system capable of arithmetic, there are statements that are True but Unprovable.

He did this by creating a “Gödel Sentence” (GG), which states:

“This statement cannot be proved within this axiomatic system.”

Let’s look at the logical trap:

  • If the system can prove GG, then GG is false (because GG says it can’t be proved). This means the system proves something false—it is Inconsistent.
  • If the system cannot prove GG, then GG is true (because it correctly says it can’t be proved). This means there is a truth the system can’t reach—it is Incomplete.

We prefer Consistency over Completeness. Thus, math is incomplete.

2. A Coding Analogy: The Halting Problem

The Halting Problem in computer science is the direct descendant of Gödel’s work. It proves that you cannot write a program will_halt(code) that correctly predicts if any given piece of code will eventually stop or run forever.

python
1# A simplified demonstration of the 'Turing Trap'
2def will_halt(func):
3 # Imagine this is a perfect predictor...
4 pass
5 
6def paradox():
7 if will_halt(paradox):
8 while True: # If it says I halt, I run forever
9 pass
10 else:
11 return # If it says I run forever, I halt
12 
13# The logic of the predictor must fail here.
14 

3. The Second Theorem: Trusting the Foundation

Gödel’s second theorem is even more startling: A system cannot prove its own consistency.

If you use a system (like ZFC) to prove that ZFC has no contradictions, you are essentially “grading your own homework.” To prove ZFC is consistent, you need a stronger system with more axioms. But that stronger system then needs an even stronger one to prove its consistency, and so on, forever.

4. Summary of the Course

We have climbed the ladder of abstraction:

  1. Propositional Logic: Computing with Bits.
  2. Predicate Logic: Quantifying the World.
  3. Boolean Algebra: Designing Circuits.
  4. Axioms: The Rules of the Game.
  5. Incompleteness: The limits of the Game.

Exercises

What is the core message of Gödel's First Incompleteness Theorem?

Why can't we just add the unprovable statement as a new axiom?

Section Detail

Propositional Logic

Propositional Logic

Propositional logic is the branch of logic that deals with propositions—statements that are either definitely True (T) or definitely False (F). It is the language that computers reflect in their hardware, where every signal is high (1) or low (0).

1. What is a Proposition?

A proposition must have a fixed truth value.

  • Propositions:
    • “The sun is a star.” (True)
    • “2 + 2 = 5.” (False)
  • Non-Propositions:
    • “Close the door!” (Command)
    • “What time is it?” (Question)
    • “This sentence is false.” (The Liar’s Paradox - it cannot be consistently True or False)

2. Logical Operators in Code

In programming, we use operators to combine these truth values. Let’s see how the basic connectives behave using Python’s boolean logic.

python
1# Logical Truth Tables in Python
2def truth_table():
3 print("P | Q | P AND Q | P OR Q | NOT P")
4 print("-" * 45)
5 for P in [True, False]:
6 for Q in [True, False]:
7 res_and = P and Q
8 res_or = P or Q
9 res_not = not P
10 print(f"{str(P):<6} | {str(Q):<6} | {str(res_and):<7} | {str(res_or):<6} | {str(res_not):<5}")
11 
12truth_table()
13 

3. The Implication (    \implies)

The implication “If PP, then QQ” is a promise. It is only broken (False) if PP is True but QQ fails to happen (is False).

Example: “If you pass the exam (PP), I will buy you a car (QQ).”

  • If you pass (P=TP=T) and you get the car (Q=TQ=T): Promise kept.
  • If you pass (P=TP=T) but you don’t get the car (Q=FQ=F): Promise broken.
  • If you fail (P=FP=F): It doesn’t matter if I buy you a car or not; the promise wasn’t triggered. Therefore, the statement is vacuously true.

4. De Morgan’s Laws in Action

De Morgan’s laws allow us to simplify complex logic. In code, this is vital for readability.

  • not (A and B) is the same as (not A) or (not B)
  • not (A or B) is the same as (not A) and (not B)
python
1# Testing De Morgan's Law
2A = True
3B = False
4 
5# Left side: not (A and B)
6lhs = not (A and B)
7# Right side: (not A) or (not B)
8rhs = (not A) or (not B)
9 
10print(f"not (A and B): {lhs}")
11print(f"(not A) or (not B): {rhs}")
12print(f"They are equal: {lhs == rhs}")
13 

Exercises

When is the statement 'P AND Q' true?

Which of the following is NOT a proposition?

Section Detail

Mathematical Notation and Logic

Mathematical Notation and Logic

Mathematics uses a concise symbolic language to express complex ideas. Understanding this notation is essential for reading and writing formal proofs.

Logical Operators

The building blocks of mathematical logic are propositions and operators:

  • Negation (¬P\neg P): “Not PP“.
  • Conjunction (PQP \land Q): ”PP and QQ“.
  • Disjunction (PQP \lor Q): ”PP or QQ“.
  • Implication (P    QP \implies Q): “If PP, then QQ“.
  • Equivalence (P    QP \iff Q): ”PP if and only if QQ“.
python
1def logical_implication(p, q):
2 # P => Q is equivalent to (not P) or Q
3 return (not p) or q
4 
5print("Truth Table for P => Q")
6print("P | Q | P => Q")
7for p in [True, False]:
8 for q in [True, False]:
9 print(f"{p} | {q} | {logical_implication(p, q)}")

Quantifiers

Quantifiers allow us to make statements about sets of elements:

  • Universal Quantifier (\forall): “For all”.
  • Existential Quantifier (\exists): “There exists”.
python
1numbers = [1, 2, 3, 4, 5]
2 
3# For all x in numbers, x > 0
4all_positive = all(x > 0 for x in numbers)
5print(f"Universal (forall x > 0): {all_positive}")
6 
7# There exists x in numbers such that x is even
8exists_even = any(x % 2 == 0 for x in numbers)
9print(f"Existential (exists x even): {exists_even}")

What is the negation of 'For all x, P(x) is true'?

Set Notation

  • xAx \in A: ”xx is an element of AA“.
  • ABA \subseteq B: ”AA is a subset of BB“.
  • ABA \cap B: Intersection.
  • ABA \cup B: Union.

If A = {1, 2} and B = {2, 3}, what is A intersect B?

Section Detail

Number Theory

Number Theory: The Queen of Mathematics

Number theory is the study of the set of integers Z\mathbb{Z}. While the objects of study are simple, the problems are among the most difficult and beautiful in all of mathematics.

1. Prime Numbers and Factorization

A prime number is an integer p>1p > 1 whose only divisors are 11 and itself. The Fundamental Theorem of Arithmetic states that every integer n>1n > 1 has a unique prime factorization.

Primes are the “atoms” of the number system. We can find them efficiently using the Sieve of Eratosthenes.

python
1def sieve(n):
2 primes = [True] * (n + 1)
3 p = 2
4 while (p * p <= n):
5 if (primes[p]):
6 for i in range(p * p, n + 1, p):
7 primes[i] = False
8 p += 1
9 return [p for p in range(2, n + 1) if primes[p]]
10 
11# Find all primes up to 100
12print(f"Primes up to 100: {sieve(100)}")

2. Greatest Common Divisor (GCD)

The GCD of two integers aa and bb is the largest positive integer that divides both. The Euclidean Algorithm calculates this by repeatedly applying the remainder operation: gcd(a,b)=gcd(b,amodb)\text{gcd}(a, b) = \text{gcd}(b, a \bmod b).

python
1def gcd(a, b):
2 while b:
3 a, b = b, a % b
4 return a
5 
6print(f"GCD of 48 and 18: {gcd(48, 18)}")
7print(f"GCD of 101 and 103: {gcd(101, 103)}")

3. Modular Arithmetic: “Clock Math”

In modular arithmetic, we work with remainders. We say ab(modn)a \equiv b \pmod{n} if nn divides (ab)(a-b). This system forms a Ring, which is the basis for modern cryptography (like RSA).

What is 17 mod 5?

4. Bezout’s Identity and Modular Inverses

Bezout’s Identity states that for any non-zero a,ba, b, there exist integers x,yx, y such that ax+by=gcd(a,b)ax + by = \text{gcd}(a, b). We can find these coefficients using the Extended Euclidean Algorithm. This is how we find Modular Inverses, which allow us to “divide” in modular arithmetic.

python
1def extended_gcd(a, b):
2 if a == 0:
3 return b, 0, 1
4 gcd, x1, y1 = extended_gcd(b % a, a)
5 x = y1 - (b // a) * x1
6 y = x1
7 return gcd, x, y
8 
9# Find modular inverse of 3 mod 11
10# We need x such that 3x = 1 (mod 11)
11g, x, y = extended_gcd(3, 11)
12if g == 1:
13 print(f"Modular inverse of 3 mod 11 is: {x % 11}")

5. Summary Check

If gcd(a, n) = 1, then a is said to be ___ to n.

Section Detail

Number Systems and Arithmetic

Number Systems and Arithmetic

The study of mathematics begins with numbers. We build complex systems from simple foundations, starting with the natural numbers.

The Hierarchy of Numbers

  1. Natural Numbers (N\mathbb{N}): {0,1,2,3,}\{0, 1, 2, 3, \dots\} (counting numbers).
  2. Integers (Z\mathbb{Z}): {,2,1,0,1,2,}\{\dots, -2, -1, 0, 1, 2, \dots\}.
  3. Rational Numbers (Q\mathbb{Q}): Fractions p/qp/q where p,qZp, q \in \mathbb{Z} and q0q \neq 0.
  4. Real Numbers (R\mathbb{R}): Includes irrational numbers like 2\sqrt{2} and π\pi.
  5. Complex Numbers (C\mathbb{C}): Numbers of the form a+bia + bi.
python
1import numpy as np
2 
3def classify_number(n):
4 if isinstance(n, complex):
5 return "Complex"
6 if n % 1 == 0:
7 return "Integer/Natural"
8 return "Fractional/Real"
9 
10test_cases = [42, 3.1415, complex(1, 2)]
11for n in test_cases:
12 print(f"{n} is {classify_number(n)}")

Peano Axioms

The natural numbers are rigorously defined by the Peano axioms, which use a single constant 00 and a successor function S(n)S(n).

  • 00 is a natural number.
  • For every nn, S(n)S(n) is a natural number.
  • No two numbers have the same successor.
  • 00 is not the successor of any number.

Fundamental Theorem of Arithmetic

Every integer greater than 1 either is a prime number itself or can be represented as a unique product of prime numbers.

python
1def prime_factors(n):
2 i = 2
3 factors = []
4 while i * i <= n:
5 if n % i:
6 i += 1
7 else:
8 n //= i
9 factors.append(i)
10 if n > 1:
11 factors.append(n)
12 return factors
13 
14print(f"Factors of 12: {prime_factors(12)}")
15print(f"Factors of 37: {prime_factors(37)}")

Which set of numbers is defined as the set of all possible ratios of integers?

What is the only even prime number?

Section Detail

Numerical Root Finding

Numerical Root Finding

Numerical root finding is the process of finding an approximate value xx such that f(x)=0f(x) = 0 for a given continuous function ff.

The Bisection Method

The Bisection method is a robust but slow root-finding algorithm. It works by repeatedly bisecting an interval and then selecting a subinterval in which a root must lie for further processing. It requires that the function values at the endpoints of the interval have opposite signs (Bolzano’s Theorem).

python
1def f(x):
2 return x**3 - x - 2
3 
4def bisection(a, b, tol=1e-5):
5 if f(a) * f(b) >= 0:
6 return "Bisection fails (no sign change)."
7
8 while (b - a) / 2 > tol:
9 midpoint = (a + b) / 2
10 if f(midpoint) == 0:
11 return midpoint
12 elif f(a) * f(midpoint) < 0:
13 b = midpoint
14 else:
15 a = midpoint
16 return (a + b) / 2
17 
18root = bisection(1, 2)
19print(f"Bisection root: {root:.6f}")
20print(f"f(root): {f(root):.6e}")

Newton-Raphson Method

The Newton-Raphson method uses the first two terms of the Taylor series to iteratively improve an estimate. xn+1=xnf(xn)f(xn)x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}

python
1def f(x):
2 return x**3 - x - 2
3 
4def df(x):
5 return 3*x**2 - 1
6 
7def newton(x0, tol=1e-5, max_iter=100):
8 x = x0
9 for i in range(max_iter):
10 delta = f(x) / df(x)
11 x = x - delta
12 if abs(delta) < tol:
13 return x, i
14 return x, max_iter
15 
16root, iterations = newton(1.5)
17print(f"Newton root: {root:.6f} found in {iterations} iterations")

Which method is generally faster if a good initial guess is provided?

Convergence and Stability

Newton’s method converges quadratically (en+1Cen2e_{n+1} \approx C e_n^2), meaning the number of correct digits roughly doubles each iteration. However, it can fail or diverge if f(x)f'(x) is near zero or if the initial guess is far from a root.

What happens to Newton's method if the derivative is zero at the current guess?

Section Detail

Predicate Logic

Predicate Logic (First-Order Logic)

Propositional logic is great for simple true/false statements, but it can’t handle variables. We cannot say “x is even” in propositional logic because xx is unknown. Predicate Logic solves this by introducing variables and Quantifiers.

1. Predicates as Functions

A Predicate is a statement whose truth depends on one or more variables. In programming, a predicate is simply a function that returns a Boolean.

python
1# A Predicate function in Python
2def is_even(n):
3 return n % 2 == 0
4 
5# Test the predicate with different values
6numbers = [1, 2, 3, 4, 5]
7for n in numbers:
8 print(f"Is {n} even? {is_even(n)}")
9 

The expression ”xx is even” is written as P(x)P(x). It is not true or false until you provide an xx.

2. Quantifiers: For All and There Exists

Quantifiers describe the scope of a predicate over a Domain (a set of objects).

  1. Universal (x\forall x): Reads “For all x…“. The statement is true only if the predicate holds for every element in the domain.
  2. Existential (x\exists x): Reads “There exists an x…“. The statement is true if there is at least one element that satisfies the predicate.

In Python, we use the all() and any() functions to represent these quantifiers.

python
1# Domain of integers
2domain = [2, 4, 6, 8, 10]
3 
4# Universal Quantifier: Are ALL numbers even?
5forall_even = all(n % 2 == 0 for n in domain)
6 
7# Existential Quantifier: Does there exist a number > 5?
8exists_greater_5 = any(n > 5 for n in domain)
9 
10print(f"Domain: {domain}")
11print(f"For all n, n is even: {forall_even}")
12print(f"Exists n such that n > 5: {exists_greater_5}")
13 

3. Negating Quantifiers

Negating a quantifier flips its type. This is a common point of confusion in both math and natural language.

  • ¬(x,P(x))x,¬P(x)\neg (\forall x, P(x)) \equiv \exists x, \neg P(x)
    • ”It’s not true that everyone is rich”     \iff “There exists someone who is not rich."
  • ¬(x,P(x))x,¬P(x)\neg (\exists x, P(x)) \equiv \forall x, \neg P(x)
    • "There is no one who is immortal”     \iff “Everyone is mortal.”

4. The Order of Quantifiers

When you nest quantifiers, the order matters immensely for the meaning of the statement.

  • x,y\forall x, \exists y such that Father(y,x)Father(y, x): “Everyone has a father.” (True for humans)
  • y,x\exists y, \forall x such that Father(y,x)Father(y, x): “There is one man who is the father of everyone.” (False for humans)

Exercises

If the domain is all positive integers, which statement is true?

Negate the statement: 'Every bird can fly'.

Section Detail

Prime Number Distribution

Prime Number Distribution

Primes are scattered along the number line in a way that appears random at small scales, but follows strict mathematical laws at large scales.

1. The Prime Counting Function π(x)\pi(x)

The function π(x)\pi(x) counts the number of primes less than or equal to xx. For example, π(10)=4\pi(10) = 4 (the primes are 2, 3, 5, 7).

python
1def count_primes(x):
2 # Sieve of Eratosthenes to count
3 primes = [True] * (x + 1)
4 for p in range(2, int(x**0.5) + 1):
5 if primes[p]:
6 for i in range(p * p, x + 1, p):
7 primes[i] = False
8 return sum(primes[2:])
9 
10print(f"pi(100) = {count_primes(100)}")
11print(f"pi(1000) = {count_primes(1000)}")

2. The Prime Number Theorem (PNT)

The PNT describes the asymptotic distribution of primes. It states that: π(x)xlnx\pi(x) \sim \frac{x}{\ln x} This means that the density of primes near xx is approximately 1/lnx1/\ln x.

python
1import numpy as np
2import matplotlib.pyplot as plt
3 
4def pi_approx(x): return x / np.log(x)
5 
6x_vals = np.linspace(10, 1000, 100)
7y_pnt = pi_approx(x_vals)
8 
9plt.plot(x_vals, y_pnt, label='x / ln x', linestyle='--')
10plt.title("The Density of Primes (Asymptotic)")
11plt.xlabel("x")
12plt.ylabel("pi(x)")
13plt.legend()
14plt.show()

3. The Riemann Zeta Function

The distribution of primes is perfectly encoded in the Riemann Zeta Function: ζ(s)=n=11ns=pPrimes11ps\zeta(s) = \sum_{n=1}^\infty \frac{1}{n^s} = \prod_{p \in \text{Primes}} \frac{1}{1 - p^{-s}}

This link, discovered by Euler and expanded by Riemann, connects prime numbers (arithmetic) to complex analysis (calculus over complex numbers).

If the density of primes is 1/ln x, are primes more frequent as x increases?

4. The Twin Prime Conjecture

Twin primes are pairs of primes that differ by 2, such as (3,5)(3, 5) and (11,13)(11, 13). The conjecture states that there are infinitely many such pairs.

python
1def get_twin_primes(limit):
2 primes = [True] * (limit + 1)
3 for p in range(2, int(limit**0.5) + 1):
4 if primes[p]:
5 for i in range(p * p, limit + 1, p):
6 primes[i] = False
7
8 prime_list = [p for p in range(2, limit + 1) if primes[p]]
9 twins = []
10 for i in range(len(prime_list) - 1):
11 if prime_list[i+1] - prime_list[i] == 2:
12 twins.append((prime_list[i], prime_list[i+1]))
13 return twins
14 
15print(f"Twin primes up to 200: {get_twin_primes(200)}")

5. Summary Check

What is the non-trivial zeros hypothesis of the Riemann Zeta Function called?

Section Detail

Projective Geometry

Projective Geometry

Projective geometry studies geometric properties that are invariant under projective transformations. It extends Euclidean geometry by adding “points at infinity.”

Homogeneous Coordinates

In nn-dimensional projective space Pn\mathbb{P}^n, a point is represented by (n+1)(n+1) coordinates [x0:x1::xn][x_0 : x_1 : \dots : x_n], where not all are zero. Two sets of coordinates represent the same point if they are scalar multiples of each other: [x]=[λx]for λ0[x] = [\lambda x] \quad \text{for } \lambda \neq 0

For the projective line P1\mathbb{P}^1, the point [1:0][1 : 0] represents the point at infinity.

python
1def to_homogeneous(x, y):
2 return [x, y, 1]
3 
4def from_homogeneous(coords):
5 x, y, w = coords
6 if w == 0:
7 return "Point at infinity"
8 return [x/w, y/w]
9 
10# A standard point
11p1 = to_homogeneous(5, 10)
12print(f"Homogeneous: {p1} -> Euclidean: {from_homogeneous(p1)}")
13 
14# A scaled homogeneous point
15p2 = [10, 20, 2] # Same as [5, 10, 1]
16print(f"Scaled Homogeneous: {p2} -> Euclidean: {from_homogeneous(p2)}")

Duality

One of the most profound features of projective geometry is the principle of duality: for any theorem in two-dimensional projective geometry, there is a dual theorem obtained by interchanging the roles of “points” and “lines.”

In P2, what is the intersection of any two distinct lines?

Cross-Ratio

The cross-ratio is the fundamental invariant of projective geometry. For four collinear points A,B,C,DA, B, C, D, the cross-ratio is defined as: (A,B;C,D)=ACBDBCAD(A, B; C, D) = \frac{AC \cdot BD}{BC \cdot AD} where ACAC denotes the signed distance from AA to CC.

python
1def cross_ratio(a, b, c, d):
2 return ((c - a) * (d - b)) / ((c - b) * (d - a))
3 
4print(f"Cross ratio of 0, 1, 2, 5: {cross_ratio(0, 1, 2, 5):.2f}")
5print(f"Cross ratio of 10, 11, 12, 15: {cross_ratio(10, 11, 12, 15):.2f}")
6# Note how translation preserves the ratio!

Projective transformations (homographies) preserve which property?

Perspective and Projections

Projective geometry provides the mathematical foundation for computer vision and 3D graphics, where 3D scenes are projected onto 2D image planes (cameras).

Section Detail

Proof Techniques

Proof Techniques

A mathematical proof is an Inferential argument for a mathematical statement. It uses previously established statements, such as theorems, and follows logically sound rules. In mathematics, we are not looking for “evidence” (as in science), but for absolute certainty.

Direct Proof

In a direct proof, we assume PP is true and use logic to show that QQ must follow.

Example: Prove that if nn is an even integer, then n2n^2 is even.

  1. Assume nn is even. By definition, n=2kn = 2k for some integer kk.
  2. Square both sides: n2=(2k)2=4k2n^2 = (2k)^2 = 4k^2.
  3. Rewrite the result: n2=2(2k2)n^2 = 2(2k^2).
  4. Since 2k22k^2 is an integer, n2n^2 is in the form 2m2m, and thus n2n^2 is even.

Proof by Contradiction

To prove PP, we assume PP is false and show that this leads to an impossible logical contradiction (0=10 = 1 or xxx \neq x).

Example: Prove that 2\sqrt{2} is irrational.

  1. Assume 2\sqrt{2} is rational. Then 2=ab\sqrt{2} = \frac{a}{b} in lowest terms.
  2. 2=a2b2    a2=2b22 = \frac{a^2}{b^2} \implies a^2 = 2b^2.
  3. This means a2a^2 is even, so aa must be even (a=2ka = 2k).
  4. (2k)2=2b2    4k2=2b2    2k2=b2(2k)^2 = 2b^2 \implies 4k^2 = 2b^2 \implies 2k^2 = b^2.
  5. This means b2b^2 is even, so bb must be even.
  6. Contradiction: If both aa and bb are even, the fraction was not in lowest terms. Thus, the original assumption must be false.

Mathematical Induction

Induction is like a row of falling dominoes. To prove a statement P(n)P(n) is true for all n1n \geq 1:

  1. Base Case: Prove P(1)P(1) is true.
  2. Inductive Step: Assume P(k)P(k) is true (the “Inductive Hypothesis”) and show that P(k+1)P(k+1) must be true.

Let’s test the formula for the sum of the first nn integers: i=1ni=n(n+1)2\sum_{i=1}^n i = \frac{n(n+1)}{2}.

python
1# Testing the Sum Formula: n(n+1)/2
2def sum_formula(n):
3 return n * (n + 1) // 2
4 
5def sum_manual(n):
6 return sum(range(1, n + 1))
7 
8# Let's check if they match for various n
9n_values = [1, 10, 100, 1000]
10results = {n: (sum_manual(n) == sum_formula(n)) for n in n_values}
11 
12print("Results for various n:")
13for n, correct in results.items():
14 print(f"n={n}: Match? {correct}")
15 

By proving the inductive step, we show that if it works for kk, it guarantees work for k+1k+1, creating an infinite chain of truth.

Exercises

What is the first step in a Proof by Contradiction?

If we want to prove that 'All prime numbers are odd' is FALSE, what do we need?

Section Detail

Real Numbers and Continuity

Real Numbers and Continuity

The real numbers R\mathbb{R} extend the rationals Q\mathbb{Q} by filling in the “gaps,” allowing for a continuous number line.

Dedekind Cuts

A Dedekind cut (A,B)(A, B) is a partition of Q\mathbb{Q} such that AA has no largest element and everything in AA is less than everything in BB. This construction formally defines irrational numbers like 2\sqrt{2}.

python
1def is_in_sqrt2_cut(q):
2 # A = {q in Q | q < 0 or q^2 < 2}
3 if q < 0: return True
4 return q**2 < 2
5 
6test_rationals = [1, 1.4, 1.41, 1.414, 1.42, 1.5, 2]
7for q in test_rationals:
8 print(f"{q} in A: {is_in_sqrt2_cut(q)}")

Completeness Axiom

The Completeness Axiom states that every non-empty set of real numbers that is bounded above has a Least Upper Bound (Supremum) in R\mathbb{R}. This is what distinguishes R\mathbb{R} from Q\mathbb{Q}.

python
1import numpy as np
2 
3def find_supremum_approximation(func, bounds, steps=1000):
4 x = np.linspace(bounds[0], bounds[1], steps)
5 y = func(x)
6 return np.max(y)
7 
8# Find supremum of -x^2 + 4 on [0, 5]
9# (Should be 4 at x=0)
10f = lambda x: -x**2 + 4
11print(f"Approximated Supremum: {find_supremum_approximation(f, [0, 5])}")

Archimedean Property

The Archimedean Property states that for any xRx \in \mathbb{R}, there exists an nNn \in \mathbb{N} such that n>xn > x. This implies that there are no “infinitely large” real numbers.

Does the set of rational numbers Q satisfy the completeness axiom?

The Cantor Set

The Cantor Set is constructed by repeatedly removing the middle third of line segments. It is a classic example of a set that is uncountable but has “measure zero.”

What is the cardinality of the set of real numbers R?

Section Detail

RSA Encryption

RSA Encryption

RSA (Rivest–Shamir–Adleman) is the algorithmic backbone of modern digital security. It relies on the practical difficulty of factoring the product of two large prime numbers.

1. The Key Generation Process

The security of RSA rests on three main steps:

  1. Choose two large primes pp and qq.
  2. Compute n=pqn = pq. This nn is used as the modulus for both public and private keys.
  3. Compute Euler’s totient function ϕ(n)=(p1)(q1)\phi(n) = (p-1)(q-1).
  4. Choose an integer ee such that 1<e<ϕ(n)1 < e < \phi(n) and gcd(e,ϕ(n))=1\gcd(e, \phi(n)) = 1.
  5. Determine dd as de1(modϕ(n))d \equiv e^{-1} \pmod{\phi(n)}.
python
1def gcd(a, b):
2 while b:
3 a, b = b, a % b
4 return a
5 
6def extended_gcd(a, b):
7 if a == 0: return b, 0, 1
8 d, x1, y1 = extended_gcd(b % a, a)
9 x = y1 - (b // a) * x1
10 y = x1
11 return d, x, y
12 
13def mod_inverse(e, phi):
14 d, x, y = extended_gcd(e, phi)
15 return x % phi
16 
17p, q = 61, 53
18n = p * q
19phi = (p-1) * (q-1)
20e = 65537 # Common choice for e
21d = mod_inverse(e, phi)
22 
23print(f"Public Key (e, n): ({e}, {n})")
24print(f"Private Key (d, n): ({d}, {n})")

2. Encryption and Decryption

A message MM is encrypted into ciphertext CC using the public key (e,n)(e, n): CMe(modn)C \equiv M^e \pmod n

The original message is recovered using the private key (d,n)(d, n): MCd(modn)M \equiv C^d \pmod n

python
1# Use the keys from the previous step
2p, q = 61, 53
3n, e = p*q, 65537
4d = 2753 # Computed in step 1
5 
6def encrypt(m, e, n):
7 return pow(m, e, n)
8 
9def decrypt(c, d, n):
10 return pow(c, d, n)
11 
12message = 42
13ciphertext = encrypt(message, e, n)
14decrypted = decrypt(ciphertext, d, n)
15 
16print(f"Original: {message}")
17print(f"Encrypted: {ciphertext}")
18print(f"Decrypted: {decrypted}")

3. Why it Works (Euler’s Theorem)

RSA works because MedMkϕ(n)+1M(modn)M^{ed} \equiv M^{k\phi(n) + 1} \equiv M \pmod n. According to Euler’s Totient Theorem, if gcd(M,n)=1\gcd(M, n) = 1, then Mϕ(n)1(modn)M^{\phi(n)} \equiv 1 \pmod n.

What happens if an attacker finds out p and q?

4. Key Takeaways

  • One-way function: Multiplication of primes is easy, but factoring their product is hard.
  • Asymmetric: You share the public key with everyone but keep the private key secret.

Which value is part of the public key?