LA1
Vector spaces
A vector space is a set where you can add elements and scale them by numbers, and where those two operations obey the rules you already use without thinking. Nothing else: no lengths, no angles, no coordinates, no arrows. Every model in machine learning lives in one, because data, weights, gradients and even functions can be added and scaled.
Needs: F1 Sets, families and intersections. Used by: LA2 Span, and everything after.
The numbers: fields
Section titled “The numbers: fields”You scale vectors by numbers, so first we fix what “numbers” are allowed to be.
Definition LA1.1Field#
A field is a set with two operations , addition and multiplication, such that:
- addition and multiplication are associative and commutative;
- there exist elements in such that and for all ;
- every has an additive inverse with , and every has a multiplicative inverse with ;
- multiplication distributes over addition: for all .
Compare: Axler, LADR 4e, “Digression on fields” (ch. 1A)
| Set | Field? | Why |
|---|---|---|
| , , | yes | all the rules hold |
| , arithmetic mod 2 | yes | ; check the rest by hand |
| no | has no inverse: | |
| float64 numbers | no | addition is not associative (below) |
Convention LA1.2F means ℝ or ℂ#
On this site stands for or unless a page says otherwise. Elements of are called scalars.
Full explanationWhy a field, and why your computer doesn't have one
The field rules are exactly what you need to solve for things. Linear algebra constantly finds unknown coefficients, and finding them means dividing. Integers fail here: you cannot solve in .
Floating-point numbers also fail, in a way that matters in practice. In float64,
Associativity is broken by rounding. In float32, while : added to the large number first, the is absorbed by rounding. This is why summing the same numbers in a different order (on another GPU, or with another batch split) can give slightly different results, and why numerical code is written to keep rounding under control. The mathematics on this site is exact, over or ; computers approximate it.
Who uses which field. is the default in machine learning. appears wherever there are rotations and frequencies: Fourier transforms, signal processing, quantum computing, and rotary position embeddings in transformers, which rotate pairs of coordinates by an angle that grows with position (the same thing as multiplying complex numbers by ). is the field of bits: error-correcting codes, cryptography and hashing do linear algebra over it.
The definition
Section titled “The definition”Definition LA1.3Vector space#
A vector space over is a set together with
- an addition , written , and
- a scalar multiplication , written ,
such that for all and all :
| Axiom | Name | |
|---|---|---|
| VS1 | commutativity | |
| VS2 | associativity | |
| VS3 | there is with for all | additive identity |
| VS4 | for each there is with | additive inverse |
| VS5 | compatibility of scaling | |
| VS6 | scaling by one | |
| VS7 | distributivity over vectors | |
| VS8 | distributivity over scalars |
Elements of are called vectors.
Compare: Axler, LADR 4e, Definition 1.20; Hoffman & Kunze, §2.1
Full explanationHow to read the definition
The operations are part of the data. A vector space is not just a set; it is a set with a particular addition and scaling. The same set with different operations can be a vector space or not (see LA1.8 and LA1.9).
Closure is built in. Writing addition as a function already says that the sum of two vectors is again in . Some books list “closure” as two extra axioms. Here it lives in the arrows.
What is not there. Nothing in the definition mentions length, angle, distance, coordinates, multiplying two vectors together, or infinite sums. Those are extra structure added later (norms, inner products, bases). Keeping them out is what lets the same theorems apply to arrows in the plane, to polynomials and to probability-weighted functions.
“Vector” is a role, not a shape. A vector is anything that lives in a vector space. A function, a matrix or an image is a vector as soon as you put it in a space where it can be added and scaled.
Examples: one space that contains the others
Section titled “Examples: one space that contains the others”Example LA1.4Fⁿ#
, the -tuples of scalars, with componentwise operations: and . The zero vector is .
Rather than checking eight axioms again for matrices, sequences, images and functions, prove them once for the space that contains all of these as special cases.
Theorem LA1.5Functions into a field form a vector space#
For any set , the set of all functions is a vector space with pointwise operations:
Its zero vector is the constant function , and the additive inverse of is .
Proofof LA1.5
Each axiom, evaluated at a point , becomes a rule of the field . For VS2: , using associativity in . Two functions that agree at every point are equal, so . VS1 and VS5–VS8 go the same way, each using the matching field rule. VS3: . VS4: .
Now choose the index set (recall F1, “A vector is a function”):
| Choose | is | Who uses it |
|---|---|---|
| every feature vector, embedding and gradient | ||
| matrices | weight matrices, covariance matrices, attention scores | |
| a pixel grid | colour images | computer vision |
| infinite sequences | signals, time series, generating functions | |
| or | real functions | function approximation, kernels, Gaussian processes |
Example LA1.6Polynomials#
is the set of polynomial functions with coefficients in , and those of degree at most (including the zero polynomial). With the usual addition and scaling of functions both are vector spaces: in fact they sit inside as subspaces (LA1.13).
Full explanationWhere polynomials fit, and a trap over small fields
Polynomials are the first function space most people meet, and the right picture is a subspace of the big space of all functions: the ones you can build from with finitely many additions and scalings. LA2 makes “build from” precise; it is called the span.
They matter because they are the functions a computer can evaluate exactly with and . Taylor expansions approximate smooth functions by polynomials; polynomial regression fits to data; the polynomial kernel in kernel methods and SVMs corresponds to a feature space of polynomials. Over finite fields, polynomials are the backbone of Reed–Solomon codes, which protect data on QR codes and storage disks.
A trap. A polynomial (a list of coefficients) and a polynomial function (what it does to inputs) are the same thing over and , because a non-zero polynomial has only finitely many roots. Over they differ: and are different polynomials, but as functions on they are identical, since and . This is why Axler restricts to and when he defines polynomials as functions.
Example LA1.7The zero space#
, a single vector with and , is a vector space. It is the smallest one, and it turns up as the span of nothing (LA2).
What is not a vector space
Section titled “What is not a vector space”A definition is understood when you can break it. Each non-example below breaks the definition at a specific point, often closure (the arrows in LA1.3). Example 2 isolates a single axiom, which shows that axiom is doing real work.
Non-example LA1.8Broken examples, one axiom at a time#
- The positive reals with ordinary and scaling. Scaling by leaves the set: . Scalar multiplication is not a function . There is no zero vector either: with ordinary addition, forces to be the real number , which is not in , so VS3 fails.
- with ordinary addition but . VS5, VS7 and VS8 still hold (check them), but VS6 fails: . So VS6 is not a consequence of the others.
- () as a space over . : scaling leaves the set.
- Probability vectors with ordinary operations. Adding two of them gives total , not ; and with ordinary addition the zero vector would have to be , which is not in the set.
- Unit vectors , with the Euclidean length and . The sum of two unit vectors is rarely a unit vector, and the zero vector (forced to be , as in 4) is missing.
Example LA1.9The same set, different operations: now it is a vector space#
Take the positive reals again, as a space over , but define “addition” as and “scaling” as . Every axiom holds. The zero vector is (since ), the inverse of is , and VS8 reads .
Full explanationWhat the positive-reals example teaches
The set did not change; the operations did, and that decided everything. The logarithm translates this strange space into ordinary : and . Products become sums and powers become scalings. Later you will call such a translation an isomorphism.
You use this translation constantly in machine learning: likelihoods are products of probabilities, and taking logs turns them into sums of log-probabilities, which are easier to differentiate and do not underflow. Non-examples 4 and 5 matter for the same reason. Softmax outputs live on the probability simplex, and normalised embeddings live on the unit sphere. Neither is a vector space. On the simplex, sums, differences and scalings leave the set, although averages stay inside (the simplex is convex); on the unit sphere even averages leave it. That is why models apply softmax or re-normalise after doing linear algebra in the full space .
What the axioms already imply
Section titled “What the axioms already imply”Some facts look too obvious to prove. Proving them is how you find out which axioms they depend on, and it is the first practice at reasoning from definitions alone.
Theorem LA1.10First consequences#
In every vector space , for all and :
- the zero vector is unique;
- each has exactly one additive inverse, written ;
- (scalar zero times is the zero vector);
- ;
- .
Proofof LA1.10
- Let and both satisfy VS3. Then , using VS3 for , VS1, then VS3 for .
- Let and both be inverses of . Then , using VS3, VS2 and VS1.
- by VS8. Add to both sides and simplify with VS2, VS4 and VS3: .
- by VS7; add to both sides as in 3.
- , using VS6, VS8 and part 3. So is an inverse of , and by part 2 it is the inverse, .
Check In the strange space of LA1.9 (positive reals over ℝ, x ⊕ y = xy, a ⊙ x = x^a), what does part 3 of LA1.10, 0v = 0, say in ordinary notation?
The scalar times is , and the zero vector of this space is . So "" becomes : a familiar fact, here forced by the axioms.
Subspaces
Section titled “Subspaces”Definition LA1.11Subspace#
A subset is a subspace of if is itself a vector space with the addition and scalar multiplication of .
Theorem LA1.12Subspace test#
is a subspace if and only if
- ;
- implies ;
- and implies .
Compare: Axler, LADR 4e, §1C; Hoffman & Kunze, §2.2, Theorem 1
Proofof LA1.12
() If is a subspace, its operations are those of and land in , which gives 2 and 3. has its own zero with . Adding the inverse of in to both sides gives , so .
() By 2 and 3 the operations of restrict to functions and . Axioms VS1, VS2 and VS5–VS8 hold for all vectors of , so in particular for those in . VS3 holds by 1. For VS4, take : by 3, , and by LA1.10, so has its inverse inside .
Example LA1.13Subspaces, and look-alikes that aren't#
Subspaces. and itself. Lines and planes through the origin in . The solution set of a homogeneous linear system. . Continuous functions inside . Sequences with only finitely many non-zero terms inside .
Not subspaces. A line that misses the origin, such as (no ). The solutions of with (no ). The union of the -axis and the -axis (not closed under addition). The unit disc (not closed under scaling). Polynomials of degree exactly ( has no degree ).
Theorem LA1.14Intersections of subspaces are subspaces#
The intersection of any non-empty family of subspaces of is a subspace of .
Compare: Hoffman & Kunze, §2.2, Theorem 2
Proofof LA1.14
Let be a non-empty family of subspaces and . Apply the subspace test. (1) Every contains , so . (2) If , then for every ; each is closed under addition, so for every , hence . (3) Scaling is identical.
Unions do not behave this way: the two axes are subspaces, their union is not. To get the smallest subspace containing both, you intersect all the subspaces that contain them, exactly as in F1.15. That subspace is the span, the subject of LA2.
Check Is {(x, y, z) ∈ ℝ³ : x + y + z = 0} a subspace? And {(x, y, z) : x + y + z = 1}?
The first is: it contains , and sums and multiples of solutions are solutions. It is a plane through the origin. The second is not: is missing (). It is the same plane shifted.
Check ℂ is a vector space over ℂ and also over ℝ. Is ℝ a subspace of ℂ?
It depends on the field. Over , yes: real multiples of reals are real. Over , no: . “Subspace” always means subspace over a given field.
Check In non-example LA1.8(2), verify that VS7 holds: a ⊙ (u + v) = a ⊙ u + a ⊙ v.
With , : . Only VS6 breaks.
Sources
Section titled “Sources”- Sheldon Axler, Linear Algebra Done Right, 4th ed. (open access, 2024): fields (ch. 1A), Definition 1.20 (vector space), §1C (subspaces).
- Kenneth Hoffman & Ray Kunze, Linear Algebra, 2nd ed. (1971): §2.1 (vector spaces), §2.2 Theorems 1–2 (subspace test, intersections of subspaces).
- Deisenroth, Faisal & Ong, Mathematics for Machine Learning (2020): §2.4 (vector spaces), for a second, more applied angle.