← All articles
BlogMaths, Programming and MLOps

What linear algebra concepts do you actually need for AI modules?

Maths, Programming and MLOpsBy Sotiris Spyrou·Published 2026-07-30
What linear algebra concepts do you actually need for AI modules?

What linear algebra concepts do you actually need for AI modules?

To succeed in an artificial intelligence or machine learning module, you need a firm grasp of vectors and matrices for data representation, dot products for measuring similarity, matrix multiplication for neural network transformations, and eigendecomposition for dimensionality reduction. Mastering these four foundational areas allows you to follow how algorithms process inputs, calculate weights, and update parameters during training.

Many students panic when they see the mathematics prerequisites for an AI syllabus. They assume they need to memorise abstract theorems and obscure proofs. In reality, university applied machine learning exams test your mechanical ability to perform specific calculations and your conceptual understanding of what those calculations represent geometrically. You are not just pushing symbols around on a page. When you multiply a matrix by a vector, you are applying a transformation to data. When you calculate an eigenvector, you are finding the axis of maximum variance in a dataset. Understanding this bridge between the raw algebra and the machine learning application is what turns a borderline pass into a first-class grade.

Linear algebra is the language that allows a computer to process multiple pieces of data simultaneously. Instead of writing inefficient loops to calculate predictions one by one, AI systems frame the entire operation as a single mathematical step. The concepts we cover below are the exact tools you will need to decipher lecture slides, write efficient code, and score highly in your final assessments.

Vectors, matrices, and data representation

Before an algorithm can learn from data, that data must be converted into a numerical format the computer can understand. This is where vectors and matrices come in. A vector is simply an ordered list of numbers, often representing a single data point. For example, a house in a property dataset might be represented by a vector containing its price, number of bedrooms, and square footage. A matrix is a two-dimensional grid of numbers, which you can think of as a collection of vectors. In machine learning, a whole dataset is typically stored as a matrix where each row is a single sample and each column is a distinct feature.

In exams, you will frequently encounter specific types of vectors and matrices that have special properties. A common example is the one-hot encoded vector used in classification tasks. If you are training an image classifier to recognise cats, dogs, and birds, a picture of a dog might be represented by the label vector [0, 1, 0]. Understanding how to manipulate these sparse vectors is critical for calculating loss functions. You must also be comfortable with basic matrix operations like transposition, which flips a matrix over its diagonal, turning rows into columns. This operation appears constantly in formulas for linear regression and backpropagation.

Beyond two dimensions, you will encounter tensors. A tensor is the mathematical generalisation of a matrix to any number of dimensions. While tabular data fits neatly into a two-dimensional matrix, a colour image requires a three-dimensional tensor to store its height, width, and three colour channels. A batch of colour images requires a four-dimensional tensor. The arithmetic rules you learn for matrices scale up to tensors, meaning a solid foundation in two-dimensional linear algebra directly prepares you for the deep learning modules that dominate the final year of an AI degree.

The dot product and measuring similarity

The dot product is arguably the single most frequent calculation you will perform in an AI exam. It takes two vectors of equal length, multiplies their corresponding elements together, and sums the results to return a single scalar value. Geometrically, the dot product tells you how much one vector points in the same direction as another. It is the core mathematical operation that underpins how neural networks measure the alignment between an input signal and the learned weights of a model.

In practical machine learning, this operation translates directly to the concept of similarity. If you normalise two vectors so their lengths are exactly one, their dot product becomes the cosine of the angle between them. This is the foundation of cosine similarity, a metric heavily used in natural language processing and recommendation systems. If you have two vectors representing the semantic meaning of two different sentences, a cosine similarity close to one indicates they mean almost the same thing, while a score of zero indicates they share no common context.

Let us look at a short worked example. Imagine you have two vectors representing user ratings for three films out of five. Vector A is [4, 2, 5] and Vector B is [3, 1, 4]. The dot product is calculated as (4 * 3) + (2 * 1) + (5 * 4). This simplifies to 12 + 2 + 20, giving a final scalar value of 34. In an exam setting, you will often need to calculate this step manually to demonstrate you understand the underlying arithmetic before applying it to a larger problem, such as computing the output of a single artificial neuron.

Matrix multiplication and neural network layers

Moving from individual vectors to entire matrices, matrix multiplication is the engine that drives neural network forward passes. When data moves from one layer of a neural network to the next, it undergoes a linear transformation followed by a non-linear activation function. The linear transformation is executed entirely through matrix multiplication. By multiplying an input matrix by a weight matrix, the network projects the data into a new mathematical space, highlighting the patterns necessary to make an accurate prediction.

The classic equation you will see in your lecture notes is y = Wx + b. Here, the weight matrix W is multiplied by the input vector x, and a bias vector b is added. A common exam trap involves the strict rules regarding matrix dimensions. To multiply two matrices, the inner dimensions must match exactly. If you have an input matrix of shape 3x4 and you wish to multiply it by a weight matrix, that second matrix must have exactly 4 rows. The resulting matrix will take on the outer dimensions of the two original matrices.

Examiners frequently test this rule by giving you a network architecture and asking you to write down the shape of the weight matrices at each specific layer. If an input layer has 128 nodes and the first hidden layer has 64 nodes, the weight matrix connecting them must be 64x128. Furthermore, in practice, we do not feed inputs into a network one by one. We feed them in batches. This changes the equation to Y = XW + b, where X is a batch of inputs. Getting these dimension calculations right on paper proves you understand how data flows through the architecture.

Eigenvalues, eigenvectors, and dimensionality reduction

As datasets grow larger and more complex, training models becomes highly computationally expensive. Principal Component Analysis, or PCA, is the standard statistical method for reducing the number of features in a dataset while retaining as much of the original variance as possible. To understand how PCA works under the hood, you must understand the concepts of eigenvalues and eigenvectors.

For a given square matrix, an eigenvector is a special vector that does not change its direction when that matrix is applied to it as a transformation. It only scales in length. The amount by which it scales is known as the eigenvalue. The defining equation you must know is Av = λv, where A is your square matrix, v is the eigenvector, and λ is the scalar eigenvalue. In the context of PCA, the matrix A is the covariance matrix of your training dataset.

The eigenvectors of this covariance matrix represent the principal components, which are the directions in which the data varies the most. The corresponding eigenvalues tell you the exact magnitude of that variance. By sorting the eigenvalues from largest to smallest, you can select the top few eigenvectors to form a new, smaller feature space. Exams frequently ask you to calculate the eigenvalues of a simple 2x2 matrix by finding the roots of its characteristic equation, which is the determinant of the matrix A minus λ times the identity matrix, set to zero.

How to answer this in an exam

Mark schemes in university AI modules are highly predictable. They reward the demonstration of methodical steps over merely arriving at the correct final number. If you make a minor arithmetic error early in a matrix multiplication but carry the incorrect value through the rest of the algorithm perfectly, a good examiner will award you follow-through marks. You only get these marks if your working is laid out clearly on the page. Writing down just the final answer is the easiest way to fail a maths-heavy AI paper.

Always state the dimensions of your matrices before you start multiplying them. Writing down a quick note stating that a 2x3 matrix multiplied by a 3x1 matrix yields a 2x1 matrix takes three seconds and immediately shows the examiner you understand the mechanics of the operation. When asked to interpret a numerical result, use precise geometric language. Do not just write down that a dot product is zero. State that the dot product is zero, meaning the two vectors are orthogonal and therefore have no linear correlation. This demonstrates the applied judgement that separates top-tier students from the rest of the cohort.

The Full Marks Press Mathematics for AI guide covers this with worked exam questions, showing exactly how marks are allocated for each step of these calculations. Practising with real mark schemes is the fastest way to train your brain to write exactly what the examiner is looking for. You must bridge the gap between knowing the theory and knowing how to communicate that theory under time pressure.

Frequently asked questions

Do I need to memorise abstract mathematical proofs to pass an AI module? No, university applied machine learning exams focus on your mechanical ability to perform calculations and your conceptual understanding of their geometric meaning.

What is the difference between a matrix and a tensor? A matrix is a two-dimensional grid of numbers used to store tabular data. A tensor is a mathematical generalisation of a matrix to any number of dimensions, which is required for data like colour images.

How do machine learning algorithms measure similarity between data points? They frequently use the dot product to evaluate the alignment between vectors. When two vectors are normalised to a length of one, their dot product produces a cosine similarity score.

Why is matrix multiplication necessary for neural networks? Matrix multiplication is the mathematical engine that drives a neural network forward pass. It executes the linear transformations required when data moves from one layer to the next.

Revising this for an exam? The Full Marks Press guides cover it with worked exam questions and mark schemes. Get a free copy.

ShareXLinkedInWhatsApp
Sotiris Spyrou

Practitioner and author at Full Marks Press, a Verity AI imprint.