Pranav Srivastava
Learning tracks
publishedBeginner to Intermediate5 chapters

Mathematics for AI

The mathematical foundation every AI practitioner needs — vectors, matrices, probability, and the calculus behind learning — explained with intuition and everyday examples, not just equations.

MathematicsLinear AlgebraProbabilityStatisticsCalculus

You can use an AI tool without knowing the maths underneath. But you cannot truly understand why it works, when it will fail, or how to fix it without a feel for four ideas: vectors, matrices, probability, and gradients. This course builds that feel — in plain language, with examples you already understand.

What you will learn
  • Picture what vectors and matrices really are — and why AI represents everything as numbers
  • Understand probability as "reasoning under uncertainty," the way every model does
  • Grasp how a model learns using gradients, with no calculus background required
  • See all four ideas working together inside a single AI prediction

Vectors — turning anything into numbers

A computer cannot understand a photo, a word, or a customer. It only understands numbers. So the first job in any AI system is to turn things into lists of numbers. That list is called a vector.

Think of describing a person to a computer. You might use: age, height in cm, and yearly income. So one person becomes [34, 178, 52000]. That is a vector — three numbers, each capturing one feature.

The magic is this: once things are vectors, closeness means similarity. Two people with vectors that sit near each other are alike. Two movies whose vectors are close get recommended to the same person. The same word — "king" and "queen" — sit near each other because their vectors are similar.

cat · kitten · felinecar · vehicle · automobilesimilar meanings sit close together
Turn things into numbers, and similar things land near each other — the idea behind search and recommendations.

This is the whole idea behind recommendations, search, and "find me more like this." Everything — images, words, songs, users — gets turned into a vector, and then AI works with distances between those points.

Chapter summary
  • A vector is just an ordered list of numbers describing something
  • Turning things into vectors lets a computer compare them
  • Closeness between vectors means similarity — the basis of search and recommendations

Matrices — machines that transform

If a vector is a single thing described as numbers, a matrix is a grid of numbers that transforms vectors. The best way to picture a matrix is as a machine: a vector goes in, a changed vector comes out.

Imagine a photo. It is a grid of numbers (each pixel's brightness). When you rotate it, brighten it, or shrink it, a matrix is doing the work — taking every pixel and moving it to a new place. Instagram filters, in essence, are matrices.

Inside a neural network, the "knowledge" the model has learned is stored as matrices. When the model makes a prediction, your input vector passes through matrix after matrix, getting transformed each step, until the final numbers come out as an answer.

You do not need to multiply matrices by hand — the computer does that billions of times a second. You only need the picture: data flows in as a vector, matrices reshape it step by step, an answer comes out.

Chapter summary
  • A matrix transforms a vector — think of it as a machine: vector in, changed vector out
  • Images, rotations, and filters are all matrix operations
  • A neural network's learned knowledge lives in its matrices
Check your understanding
  1. In your own words, what is the difference between a vector and a matrix?
  2. Why does turning a photo or a word into numbers make it useful to an AI?

Probability — reasoning when you are not sure

Real life is uncertain, and AI models live in that uncertainty. They almost never say "this is definitely a cat." They say "I am 92% sure this is a cat." Probability is the language of that uncertainty.

You already think in probabilities. A weather forecast says "70% chance of rain." That is a model expressing confidence, not certainty. Every modern AI does the same thing under the hood — it produces a list of options, each with a probability.

One idea is worth knowing by name: Bayes' theorem, which is just updating your belief when new evidence arrives. A doctor thinks a patient is probably healthy. A test comes back positive. The doctor updates — now more worried, but not certain, because tests are imperfect. Spam filters, medical AI, and fraud detection all work this way: start with a belief, update it as evidence comes in.

Chapter summary
  • Models express answers as probabilities — confidence, not certainty
  • A weather forecast is the everyday version of what a model does
  • Bayes' theorem = updating your belief as new evidence arrives (spam filters, fraud, diagnosis)

Gradients — how a model actually learns

Here is the question that unlocks all of AI: how does a model learn from examples? The answer is a beautifully simple idea called gradient descent.

Picture yourself on a foggy hillside at night, trying to reach the bottom of the valley. You cannot see far. But you can feel which way the ground slopes under your feet. So you take a small step downhill, feel again, step again. Step by step, you reach the bottom.

That is exactly how a model learns:

start · very wronglowest erroreach step feels the slope and moves a little downhill
Learning is walking downhill: feel which way reduces the error, take a small step, repeat until you reach the bottom.
  • The "height" of the hill is the model's error — how wrong it is.
  • The "slope underfoot" is the gradient — which direction reduces the error.
  • Each "step" nudges the model's numbers (its matrices) a little in the right direction.
  • Repeat millions of times, and the model walks itself down to good answers.

That is the entire learning loop, and it is the same whether the model recognises cats or writes text. The calculus you may have heard about (derivatives, the chain rule) is simply the precise way to "feel the slope." You do not need to compute it — you need to know that learning is repeated small steps downhill toward less error.

Chapter summary
  • Learning = gradient descent = repeatedly stepping "downhill" to reduce error
  • The gradient is the slope that tells the model which way to adjust
  • This single idea powers all model training, from image recognition to language
Check your understanding
  1. Using the foggy-hill picture, explain what "the model is learning" actually means.
  2. Why does a model give a probability (like 92%) instead of a flat yes or no?

All four, inside one prediction

Let us watch the four ideas work together when an AI labels a photo as "a dog":

Vector

The photo becomes a long vector of numbers (pixel brightnesses).

Matrices

That vector flows through the network's matrices, getting reshaped at each layer — edges, then shapes, then "dog-like" features.

Probability

The final numbers become a probability list: dog 0.94, cat 0.05, fox 0.01. The model reports its confidence.

Gradients (during training)

Earlier, while learning, every time the model guessed wrong, gradient descent nudged those matrices a little — until "dog" photos reliably produced high "dog" numbers.

That is the whole machine. Vectors turn the world into numbers, matrices transform them, probability expresses the answer, and gradients are how the model got good in the first place. Every course after this one builds on these four pictures.

Chapter summary
  • A single prediction uses all four ideas: vectors in, matrices transform, probability out, gradients trained it
  • You now have the mental model the rest of AI is built on
  • Nothing here required heavy maths — just the right pictures
All tracksQuestions? Get in touch →