Showing posts with label Math. Show all posts
Showing posts with label Math. Show all posts

Friday, July 24, 2026

From Math to Machine Learning: A Practical Roadmap From Math to Machine Learning: A Practical Roadmap

From Math to Machine Learning: A Practical Roadmap

Machine learning isn't just about writing Python code—it's about understanding the mathematics that powers every algorithm. Concepts like matrix multiplication, gradients, probability distributions, and statistical inference are the building blocks behind everything from recommendation systems to large language models.

One of the most fundamental operations in machine learning is matrix multiplication:

$$ C=AB $$

where A and B are matrices and C is the resulting matrix.


import numpy as np

C = np.matmul(A, B)

# or

import torch

C = torch.matmul(A, B)

Gradient descent updates model parameters using:

$$ \theta=\theta-\alpha\nabla J(\theta) $$
  • \(\theta\) — model parameters
  • \(\alpha\) — learning rate
  • \(\nabla J(\theta)\) — gradient of the loss function

Building Machine Learning Models from Mathematical Primitives

Linear Regression

Linear regression predicts continuous values using:

$$ \hat{y}=Xw+b $$

The objective is to minimize the Mean Squared Error (MSE):

$$ J(w)=\frac1n\sum_{i=1}^{n}(y_i-\hat y_i)^2 $$

Logistic Regression

The sigmoid activation converts outputs into probabilities:

$$ \sigma(z)=\frac1{1+e^{-z}} $$

Binary Cross Entropy Loss:

$$ L= -\left[ y\log(\hat y) + (1-y)\log(1-\hat y) \right] $$

Neural Networks

A neuron computes:

$$ y=\sigma(Wx+b) $$

Backpropagation applies the chain rule:

$$ \frac{\partial L}{\partial W} = \frac{\partial L}{\partial y} \cdot \frac{\partial y}{\partial W} $$

The Four Mathematical Pillars of Machine Learning

1. Linear Algebra

  • Vectors
  • Matrices
  • Matrix Multiplication
  • Eigenvalues
  • Eigenvectors
  • SVD

Dot Product:

$$ \mathbf v\cdot\mathbf w = \sum_{i=1}^{n}v_iw_i $$

2. Calculus

  • Derivatives
  • Gradients
  • Chain Rule
  • Optimization

Derivative:

$$ f'(x) = \lim_{h\rightarrow0} \frac{f(x+h)-f(x)}{h} $$

Gradient:

$$ \nabla f = \left( \frac{\partial f}{\partial x_1}, \frac{\partial f}{\partial x_2}, \ldots, \frac{\partial f}{\partial x_n} \right) $$

3. Probability

  • Random Variables
  • Bayes' Theorem
  • Gaussian Distribution
  • Likelihood

Bayes' Theorem:

$$ P(A|B) = \frac{P(B|A)P(A)} {P(B)} $$

Normal Distribution:

$$ X\sim\mathcal N(\mu,\sigma^2) $$

4. Statistics

  • Mean
  • Variance
  • Covariance
  • Correlation

Mean:

$$ \mu = \frac1n \sum_{i=1}^{n}x_i $$

Variance:

$$ \sigma^2 = \frac1n \sum_{i=1}^{n} (x_i-\mu)^2 $$

Mathematics Across Machine Learning Domains

Large Language Models (LLMs)

The attention mechanism:

$$ \mathrm{Attention}(Q,K,V) = \mathrm{softmax} \left( \frac{QK^T}{\sqrt{d_k}} \right)V $$

Reinforcement Learning

Bellman Equation:

$$ V(s) = R(s) + \gamma \sum_{s'} P(s'|s)V(s') $$

Recommender Systems

Matrix Factorization:

$$ R \approx UV^T $$

A Practical Learning Roadmap

  1. Master Linear Algebra
  2. Learn Calculus
  3. Study Probability
  4. Understand Statistics
  5. Implement concepts in NumPy
  6. Rebuild them in PyTorch
  7. Create Linear Regression
  8. Create Logistic Regression
  9. Build Neural Networks
  10. Advance to CNNs, Transformers, RL, and Recommender Systems

Conclusion

The goal isn't simply to memorize formulas—it's to understand how mathematics becomes code and how that code becomes intelligent systems. By connecting theory with implementation, machine learning becomes much more intuitive.

Whether you're an aspiring AI engineer, data scientist, or curious programmer, mastering Linear Algebra, Calculus, Probability, and Statistics provides the foundation for everything from simple regression models to modern transformers.

Thursday, June 12, 2025

x̄ - >16 must know undergraduate math proofs

Undergraduate Math Proofs to Spark Your Curiosity

Undergraduate Math Proofs to Spark Your Curiosity

Discover elegant proofs across 8 mathematical fields, perfect for students and enthusiasts!

Welcome to a journey through foundational proofs in undergraduate mathematics! From the elegance of Calculus to the structure of Abstract Algebra, these proofs are cornerstones of mathematical understanding. Click on each section to explore clear, concise explanations designed to inspire and educate.

Calculus

Intermediate Value Theorem

Statement: If \( f \) is continuous on \([a, b]\) and \( k \) is any number between \( f(a) \) and \( f(b) \), then there exists \( c \in [a, b] \) such that \( f(c) = k \).

Proof: Assume \( f(a) < k < f(b) \). Define \( g(x) = f(x) - k \). Since \( f \) is continuous, \( g \) is continuous, with \( g(a) < 0 \), \( g(b) > 0 \). Let \( S = \{ x \in [a, b] \mid g(x) \leq 0 \} \). Since \( g(a) < 0 \), \( S \) is non-empty and bounded. Let \( c = \sup S \). Since \([a, b]\) is closed, \( c \in [a, b] \). If \( g(c) > 0 \), continuity implies \( g(x) > 0 \) near \( c \), but \( c = \sup S \) implies points \( x < c \) with \( g(x) \leq 0 \), a contradiction. If \( g(c) < 0 \), then for \( x > c \), \( g(x) < 0 \), contradicting \( c = \sup S \). Thus, \( g(c) = 0 \), so \( f(c) = k \). ∎

Mean Value Theorem

Statement: If \( f \) is continuous on \([a, b]\) and differentiable on \((a, b)\), there exists \( c \in (a, b) \) such that \( f'(c) = \frac{f(b) - f(a)}{b - a} \).

Proof: Define \( g(x) = f(x) - f(a) - \frac{f(b) - f(a)}{b - a}(x - a) \). Then \( g(a) = 0 \), \( g(b) = 0 \). Since \( f \) is continuous and differentiable, so is \( g \). By Rolle’s Theorem, there exists \( c \in (a, b) \) such that \( g'(c) = 0 \). Compute: \( g'(x) = f'(x) - \frac{f(b) - f(a)}{b - a} \), so \( g'(c) = 0 \implies f'(c) = \frac{f(b) - f(a)}{b - a} \). ∎

Linear Algebra

Rank-Nullity Theorem

Statement: For a linear transformation \( T: V \to W \), \( \dim(V) = \dim(\ker T) + \dim(\text{im } T) \).

Proof: Let \( \dim(V) = n \), \( \dim(\ker T) = k \). Choose a basis \( \{ v_1, \ldots, v_k \} \) for \( \ker T \), extend to \( \{ v_1, \ldots, v_n \} \) for \( V \). The set \( \{ T(v_{k+1}), \ldots, T(v_n) \} \) spans \( \text{im } T \): for \( w \in \text{im } T \), \( w = T(v) \), \( v = \sum a_i v_i \), so \( w = \sum_{i=k+1}^n a_i T(v_i) \). For independence, if \( \sum_{i=k+1}^n b_i T(v_i) = 0 \), then \( \sum b_i v_i \in \ker T \), so \( \sum b_i v_i = \sum c_i v_i \), implying \( b_i = 0 \). Thus, \( \dim(\text{im } T) = n - k \), so \( n = k + (n - k) \). ∎

Cauchy-Schwarz Inequality

Statement: For \( \mathbf{u}, \mathbf{v} \in \mathbb{R}^n \), \( |\mathbf{u} \cdot \mathbf{v}| \leq \|\mathbf{u}\| \|\mathbf{v}\| \).

Proof: If \( \mathbf{v} = \mathbf{0} \), the inequality holds. Assume \( \mathbf{v} \neq \mathbf{0} \). Let \( t = \frac{\mathbf{u} \cdot \mathbf{v}}{\mathbf{v} \cdot \mathbf{v}} \). Then \( (\mathbf{u} - t \mathbf{v}) \cdot \mathbf{v} = 0 \). Expand \( \|\mathbf{u} - t \mathbf{v}\|^2 \geq 0 \): \( \|\mathbf{u}\|^2 - 2 t (\mathbf{u} \cdot \mathbf{v}) + t^2 (\mathbf{v} \cdot \mathbf{v}) \). Substitute \( t \): \( \|\mathbf{u}\|^2 - \frac{(\mathbf{u} \cdot \mathbf{v})^2}{\mathbf{v} \cdot \mathbf{v}} \geq 0 \). Multiply by \( \mathbf{v} \cdot \mathbf{v} \): \( \|\mathbf{u}\|^2 \|\mathbf{v}\|^2 \geq (\mathbf{u} \cdot \mathbf{v})^2 \). Take the square root. ∎

Differential Equations

Uniqueness of First-Order Linear ODE

Statement: For \( \frac{dy}{dx} + P(x)y = Q(x) \), continuous \( P, Q \), with \( y(x_0) = y_0 \), there is at most one solution.

Proof: Let \( y_1, y_2 \) be solutions with \( y_1(x_0) = y_2(x_0) \). Set \( u = y_1 - y_2 \). Then \( \frac{du}{dx} = -P(x)u \), \( u(x_0) = 0 \). Multiply by \( \mu(x) = e^{\int P(x) \, dx} \): \( \frac{d}{dx} [ \mu(x) u ] = 0 \). Thus, \( \mu(x) u(x) = C \). Since \( u(x_0) = 0 \), \( C = 0 \), so \( u(x) = 0 \), hence \( y_1 = y_2 \). ∎

Solution to Second-Order Linear ODE

Statement: For \( y'' + ay' + by = 0 \), if \( r^2 + ar + b = 0 \) has distinct roots \( r_1, r_2 \), the solution is \( y = c_1 e^{r_1 x} + c_2 e^{r_2 x} \).

Proof: Verify \( y_1 = e^{r_1 x} \): \( y_1'' + a y_1' + b y_1 = e^{r_1 x} (r_1^2 + a r_1 + b) = 0 \). Similarly for \( y_2 = e^{r_2 x} \). Linear combinations \( c_1 e^{r_1 x} + c_2 e^{r_2 x} \) are solutions, and since \( r_1 \neq r_2 \), they are linearly independent, spanning the two-dimensional solution space. ∎

Probability & Statistics

Chebyshev’s Inequality

Statement: For a random variable \( X \) with mean \( \mu \), variance \( \sigma^2 \), \( P(|X - \mu| \geq k) \leq \frac{\sigma^2}{k^2} \).

Proof: Let \( Y = (X - \mu)^2 \). Then \( E[Y] = \sigma^2 \). By Markov’s inequality, \( P(Y \geq k^2) \leq \frac{E[Y]}{k^2} = \frac{\sigma^2}{k^2} \). Since \( (X - \mu)^2 \geq k^2 \iff |X - \mu| \geq k \), the result follows. ∎

Independence Implies Zero Covariance

Statement: If \( X, Y \) are independent, then \( \text{Cov}(X, Y) = 0 \).

Proof: \( \text{Cov}(X, Y) = E[XY] - E[X] E[Y] \). Since \( X, Y \) are independent, \( E[XY] = E[X] E[Y] \). Thus, \( \text{Cov}(X, Y) = E[X] E[Y] - E[X] E[Y] = 0 \). ∎

Discrete Mathematics

Pigeonhole Principle

Statement: If \( n + 1 \) items are placed into \( n \) boxes, at least one box has at least two items.

Proof: If each box has at most one item, the total number of items is at most \( n \). But there are \( n + 1 \) items, a contradiction. Thus, at least one box has at least two items. ∎

Euler’s Theorem for Graphs

Statement: A connected graph has an Eulerian circuit if every vertex has even degree.

Proof: Start a trail at vertex \( v \). Since all degrees are even, the trail can exit any vertex entered, returning to \( v \), forming a circuit \( C \). If \( C \) omits edges, pick a vertex on \( C \) with unused edges, form another circuit in the remaining graph (still even-degree), and splice it into \( C \). Repeat until all edges are used. ∎

Abstract Algebra

Lagrange’s Theorem

Statement: If \( G \) is a finite group and \( H \) is a subgroup, \( |H| \) divides \( |G| \).

Proof: Left cosets \( gH \) partition \( G \), each with \( |H| \) elements. If there are \( k \) cosets, \( |G| = k \cdot |H| \), so \( |H| \) divides \( |G| \). ∎

Order of an Element Divides Group Order

Statement: In a finite group \( G \), the order of any element \( a \) divides \( |G| \).

Proof: Let \( n \) be the order of \( a \), so \( H = \langle a \rangle \) has \( |H| = n \). By Lagrange’s Theorem, \( n \) divides \( |G| \). ∎

Numerical Analysis

Convergence of Newton’s Method

Statement: For \( f \) with \( f'(x) \neq 0 \), \( f'' \) continuous near a root \( r \), Newton’s method converges quadratically near \( r \).

Proof: Let \( e_n = x_n - r \). By Taylor’s theorem, \( f(x_n) = f'(r)e_n + O(e_n^2) \), \( f'(x_n) = f'(r) + O(e_n) \). Newton’s step gives: \( e_{n+1} = e_n - \frac{f'(r)e_n + O(e_n^2)}{f'(r) + O(e_n)} \approx O(e_n^2) \). Thus, \( |e_{n+1}| \leq C e_n^2 \). ∎

Trapezoidal Rule Error Bound

Statement: For \( f \in C^2[a, b] \), the trapezoidal rule error is \( |E| \leq \frac{(b - a)^3}{12 n^2} \max |f''(x)| \).

Proof: For subinterval \([x_i, x_{i+1}] bag\), error \( E_i = \int_{x_i}^{x_{i+1}} \frac{f''(\xi_x)}{2} (x - x_i)(x - x_{i+1}) \, dx \). Compute: \( \int_0^h u (u - h) \, du = -\frac{h^3}{6} \). Thus, \( |E_i| \leq \frac{h^3 |f''(\xi_i)|}{12} \). Sum: \( |E| \leq \frac{n h^3}{12} \max |f''(x)| = \frac{(b - a)^3}{12 n^2} \max |f''(x)| \). ∎

Geometry & Topology

Pythagorean Theorem

Statement: In a right triangle with legs \( a, b \), hypotenuse \( c \), \( a^2 + b^2 = c^2 \).

Proof: Construct a square with side \( a + b \), containing four copies of the triangle and a central square of side \( c \). Large square area: \( (a + b)^2 = a^2 + 2ab + b^2 \). Four triangles: \( 4 \cdot \frac{1}{2}ab = 2ab \). Central square: \( c^2 \). Equate: \( a^2 + 2ab + b^2 = 2ab + c^2 \). Subtract \( 2ab \): \( a^2 + b^2 = c^2 \). ∎

Isosceles Triangle Theorem

Statement: In \( \triangle ABC \), if \( AB = AC \), then \( \angle ABC = \angle ACB \).

Proof: Draw the angle bisector of \( \angle BAC \), intersecting \( BC \) at \( D \). In \( \triangle ABD \) and \( \triangle ACD \), \( AB = AC \), \( AD = AD \), \( \angle BAD = \angle CAD \). By SAS, \( \triangle ABD \cong \triangle ACD \), so \( \angle ABC = \angle ACB \). ∎

© 2026 Math Enthusiast. Built with passion for learning.

Featured Post

3rd Place at the BAKE Blogger Awards: Thank You for the Support!

3rd Place at the BAKE Blogger Awards: Thank You for the Support! ...

Meet the Authors
Zacharia Nyambu’s blog features multiple contributors with clear activity status.
Active ✔
πŸ§‘‍πŸ’»
Zacharia Nyambu
Lead Author
Inactive ✖
πŸ‘©‍πŸ’»
Linda Bahati
Co‑Author
Inactive ✖
πŸ‘¨‍πŸ’»
Jefferson Mwangolo
Co‑Author
Inactive ✖
πŸ‘©‍πŸŽ“
Florence Wavinya
Guest Author
Inactive ✖
πŸ‘©‍πŸŽ“
Esther Njeri
Guest Author
Inactive ✖
πŸ‘©‍πŸŽ“
Clemence Mwangolo
Guest Author

Followers