Chapter 1: Vectors and linear combinations
LA 00 Course Map | Next: LA 02 Dot Product Length and Angle
A vector is a list of numbers that you are allowed to add and scale. Almost all of linear algebra comes from one question: if I add and scale a few vectors, what can I build?
- Read and write vectors, and switch between the “arrow” picture and the “list of data” picture.
- Add vectors and multiply them by numbers, by hand and geometrically.
- Write one vector as a linear combination of others, and find the weights.
- Describe the span of a set of vectors (a line, a plane, or more).
- Decide whether vectors are linearly independent, and explain what that means.
You only need school algebra: solving two equations in two unknowns, such as , . If you can do that, you are ready.
1.1 What is a vector?
Why we need them
Many things in the world need more than one number to describe them:
- A point on a map needs two numbers: how far east, how far north.
- A robot arm with three joints needs three angles.
- A colour on a screen needs three numbers: red, green, blue.
- A greyscale image is brightness values.
We want one object that holds all those numbers together, in a fixed order, so that we can do maths with the whole thing at once. That object is a vector.
The definition
A vector with entries is an ordered list of real numbers. We write it as a column:
The numbers are the entries (or components). The set of all such vectors is called (“R-n”).
Let’s unpack each word.
- “Ordered” means position matters. and are different vectors, the same way “3 east, 1 north” is a different place from “1 east, 3 north”.
- ” entries” is the dimension of the space the vector lives in. lives in , the plane. lives in , ordinary 3-D space.
- stands for the real numbers. means “pairs of real numbers”, means “triples”, and so on.
To save space in writing, people also write a vector on one line, such as . It means the same column. Later you will meet the transpose, , which really is a row; for now, treat as a shorthand for the column.
Two ways to picture a vector
You should get comfortable switching between these two pictures. Each one is good for different things.
Picture 1: an arrow. The vector is an arrow that starts at the origin and ends at the point 3 units right and 1 unit up.
y
2 |
1 | ● (3,1)
| _/
| _/
0 +----------------- x
0 1 2 3
The arrow has a direction (where it points) and a length (how long it is). This picture is wonderful in 2-D and 3-D, because you can draw it.
Picture 2: a record of data. The vector might hold the three joint angles of a robot arm, in radians. Nobody draws it as an arrow; it is just three numbers kept together.
This picture is the one you need in high dimensions. A 784-entry image vector cannot be drawn, but every rule you learn with 2-D arrows still works on it.
Learn each new idea with a 2-D arrow you can draw. Then trust that the same algebra works in any number of dimensions.
Equality
Two vectors are equal exactly when they have the same number of entries and every entry matches:
So one vector equation is really several ordinary equations, one per entry. Keep this in mind; you will use it constantly.
The zero vector
The vector with every entry equal to zero is the zero vector, written (sometimes ):
As an arrow it has no length and no direction: it is just the origin.
- Which space does live in?
- Are and equal?
- Write as two ordinary equations and solve.
Answers. 1. , since it has four entries. 2. No, order matters. 3. and , so , .
1.2 Adding vectors
The rule
To add two vectors of the same size, add matching entries:
Worked example 1.1.
Worked example 1.2.
You cannot add vectors of different sizes. is not defined, just as you cannot add a map location to a colour.
What addition means: walking
Think of a vector as an instruction to walk: means “3 steps east, 1 step north”.
Adding means: follow , then from where you ended up, follow . The sum is where you finish.
● end = (2,3)
/|
v / |
/ |
(3,1) ● | u = (3,1), then v = (-1,2)
/ |
u / |
/ |
●--------+
origin
This is the tip-to-tail rule: place the tail of at the tip of .
Why does it match the entry-by-entry rule? Walking east 3 and then east (that is, west 1) puts you at east . The east-west numbers simply add, and so do the north-south numbers. Each coordinate adds on its own.
The parallelogram
If you instead walk first and then , you finish at the same point, because (ordinary addition does not care about order). The two routes form the sides of a parallelogram, and is its diagonal.
Rules that addition obeys
These all follow directly from the same rules for ordinary numbers, entry by entry:
| Rule | Formula | In words |
|---|---|---|
| commutative | order does not matter | |
| associative | grouping does not matter | |
| zero | adding nothing changes nothing | |
| negative | walking there and back returns you home |
Here is the vector with every entry negated, for example . It points the opposite way with the same length.
Subtraction is adding the negative: .
is the arrow that goes from the tip of to the tip of . Check: start at , add , and you get .
With and : . If a robot’s hand is at and the target is at , then is exactly the move it must make.
- Compute .
- Compute and say in words what it represents if the points are positions.
- Why is not allowed?
Answers. 1. . 2. : the step needed to get from to . 3. The vectors have different sizes, so entries cannot be matched.
1.3 Scaling vectors
The rule
To multiply a vector by a number (a scalar), multiply every entry by :
“Scalar” just means “a single ordinary number”, as opposed to a vector. The name comes from what it does: it scales.
Worked example 1.3.
What scaling means
| Scalar | Effect on the arrow |
|---|---|
| same direction, longer | |
| same direction, shorter | |
| unchanged | |
| collapses to the zero vector | |
| flips to the opposite direction, then stretches by |
The important thing: scaling never turns a vector sideways. Every multiple lies on the same line through the origin as . We will use this fact many times.
Rules
| Rule | Formula |
|---|---|
| distributes over vectors | |
| distributes over scalars | |
| associative | |
| one |
Why is true? Look at one entry. On the left the entry is ; on the right it is . Those are equal by ordinary algebra. Since every entry matches, the vectors are equal. This “check one entry” argument proves all the rules in this chapter.
- Compute .
- Is a multiple of ? Is ?
- Simplify .
Answers. 1. . 2. Yes, . No: you would need from the first entry and from the second. 3. .
1.4 Linear combinations
Putting the two operations together
Now combine both operations. Take some vectors, scale each one, and add the results.
A linear combination of the vectors is any vector of the form
where are scalars, called the weights (or coefficients).
The word “linear” signals that only these two operations are used. No squaring, no multiplying vectors together, no square roots.
Worked example 1.4. With , and weights , :
The recipe picture
A good way to think about it: the vectors are ingredients, and the weights are amounts.
Suppose each paint is described by (red, green, blue) amounts per litre:
- paint A (pure red)
- paint B (pure blue)
Mixing 2 litres of A with 1 litre of B gives . Every colour you can mix is a linear combination of A and B. Notice you can never get any green, because neither ingredient has any. That observation is the seed of the idea of span in the next section.
The reverse question: finding the weights
The interesting question goes backwards: given a target vector, which weights produce it?
Worked example 1.5. Can we write as a combination of and ?
Step 1: write what we want. We need numbers with
Step 2: compute the left side. It equals .
Step 3: match entries (remember: one vector equation is several ordinary equations):
Step 4: solve. The second equation gives . Then the first gives .
Step 5: check. . Correct.
Finding weights for a linear combination is the same thing as solving a system of linear equations. This link between vectors and equation systems is the backbone of the whole course. Chapter 4 (LA 04 Solving Linear Systems) gives a method that works for any size.
Worked example 1.6 (no solution). Can be written as a combination of and ?
Matching entries:
Multiply the first equation by 2: . But the second equation says the same left side equals 5. Since , there is no solution.
Why? Look at the ingredients: . Both point along the same line, so every combination stays on that line. The target is not on it.
Worked example 1.7 (many solutions). Write using the same , . The equations are and . The second is just twice the first, so we only really have one equation with two unknowns. Choose any , say , then . For example gives , and gives . Both equal . There are infinitely many ways.
These three examples show the only three possibilities: exactly one way, no way, or infinitely many ways. Chapter 4 explains why there is never “exactly two”.
- Compute .
- Write as a combination of and .
- Can be written as a combination of and ? Why or why not?
Answers. 1. . 2. and , so , . 3. No. Every combination has first entry , but the target has first entry 1.
1.5 Span: everything you can build
The definition
The span of vectors is the set of all their linear combinations:
Read the set notation as: “all vectors of the form , where the ‘s can be any real numbers.”
In the paint analogy, the span is every colour you could possibly mix.
So “is a linear combination of the ‘s?” and “is in the span of the ‘s?” are the same question.
What spans look like
Let’s build up one vector at a time, in .
One nonzero vector. The span of is all multiples . From section 1.3, all multiples lie on one line. So:
Two vectors pointing in different directions. Combinations can move along and along freely, so they sweep out a whole flat plane through the origin.
Two vectors on the same line. If , then . That is just a multiple of . The span is still only a line. The second vector added nothing new.
Three vectors in . If the third points out of the plane of the first two, the span is all of . If it lies in that plane, the span is still just the plane.
| Vectors | Typical span | Exception |
|---|---|---|
| one nonzero vector | a line | none |
| two vectors | a plane | a line, if they are parallel |
| three vectors in | all of | a plane or line, if one is “redundant” |
Two facts that always hold
- The span always contains the zero vector. Choose all weights equal to zero.
- The span always passes through the origin. That follows from fact 1. A line that misses the origin, such as , can never be a span.
Worked example 1.8. Is in the span of and ?
We need to equal . The first two entries force , . The third entry then must be . It is. So yes: .
Now try . The same first two entries force , , but then the third entry would be . So is not in the span. The span is a plane, and this point lies just off it.
- Describe the span of in .
- Describe the span of and .
- Describe the span of and .
Answers. 1. The diagonal line . 2. All of : . 3. A line, because the second vector is times the first.
1.6 Linear independence: spotting redundancy
Motivation
In section 1.5, sometimes adding a vector made the span bigger and sometimes it did nothing. A vector that adds nothing is redundant: it can already be built from the others. We want a precise test for this.
The definition
Vectors are linearly independent if the only way to make the zero vector from them is to use all-zero weights:
Otherwise they are linearly dependent.
Why this definition captures “no redundancy”
The definition looks strange at first: why talk about making zero? Here is the reasoning.
Suppose some vector is redundant, say . Move everything to one side:
That is a way to make zero with weights , which are not all zero. So redundancy produces a nonzero recipe for zero.
It works the other way too. If with, say, , divide by and rearrange:
so is built from the others: it is redundant.
So “some vector is redundant” and “zero can be made with nonzero weights” mean exactly the same thing. The zero-based definition is preferred because it treats all the vectors equally, and it turns the question into a system of equations we can solve.
How to test for independence
- Write .
- Turn it into equations, one per entry.
- Solve. If the only solution is all zeros, the vectors are independent. If any other solution exists, they are dependent.
Worked example 1.9. Are and independent?
. The second entry gives ; then the first gives . Only the zero solution: independent.
Worked example 1.10. Are and independent?
, so with weights . A nonzero recipe for zero exists: dependent.
Worked example 1.11. Are , , independent?
Set :
From the first two, and . Substitute into the third: , which is , always true. So can be anything. Take : then , and indeed , that is . Dependent.
Quick tests you can do in your head
- Two vectors are dependent exactly when one is a multiple of the other.
- Any set containing the zero vector is dependent: is a nonzero recipe.
- Too many vectors: more than vectors in are always dependent. For example, any 3 vectors in are dependent. (Chapter 5 proves this.)
Three vectors can be dependent even when no two of them are multiples of each other, as example 1.11 shows. Checking pairs is not enough.
- Are and independent?
- Are , , independent?
- Without calculating, are , , independent?
Answers. 1. Yes: neither is a multiple of the other. 2. No: the set contains the zero vector. 3. No: three vectors in are always dependent. (In fact .)
1.7 The standard basis
In there are three especially simple vectors:
Each has a single 1 and zeros elsewhere. They point along the , and axes.
Every vector is a combination of them, and the weights are just its entries:
They have two properties:
- They span : everything can be built.
- They are independent: none can be built from the other two.
A set with both properties is called a basis. Spanning means “enough vectors”; independence means “no wasted vectors”. So a basis is a minimal, complete set of building blocks.
The standard basis is not the only basis. and also form a basis of . Choosing a clever basis is often the key to solving a problem, and that is the subject of LA 11 Change of Basis.
Summary
| Idea | Meaning | How to compute or test |
|---|---|---|
| vector | ordered list of numbers | write as a column |
| addition | walk one, then the other | add matching entries |
| scaling | stretch, shrink or flip | multiply every entry |
| linear combination | scale, then add | |
| finding weights | which recipe makes ? | match entries, solve the equations |
| span | everything you can build | a line, plane, … through the origin |
| independent | no redundant vector | only the zero recipe makes |
| basis | spans, and independent | e.g. |
Three facts to remember:
- A vector equation is a system of ordinary equations, one per entry.
- A span always passes through the origin.
- Redundancy means a nonzero recipe for the zero vector.
Exercises
Work in order. Part A builds fluency, B builds understanding, C asks for short proofs, D connects to code. Try every question before opening its solution.
Part A: warm-up
A1. Compute .
A2. Compute .
A3. Find and if .
A4. A robot hand is at metres and must move to . What displacement vector does it need?
A5. Simplify .
A1. .
A2. .
A3. gives . Then gives .
A4. Target minus start: . Move 15 cm in and 20 cm down in .
A5. .
Part B: core
B1. Write as a linear combination of and .
B2. Is in the span of and ? If so, give the weights.
B3. Is in the span of and ?
B4. Decide whether each set is independent:
(a)
(b)
(c)
B5. For which value of are and dependent?
B6. Describe geometrically the span of and in .
B7. Give three different vectors in the span of and .
B1. . Matching: so ; then so . Check: .
B2. . Need , , and third entry . Consistent, so yes: .
B3. Combinations look like . Matching the first two entries gives , , so the third would be , not . Not in the span.
B4.
(a) Dependent: .
(b) Independent. Set . The third entry gives , the second then gives , the first gives .
(c) Dependent: .
B5. Dependent when is a multiple of . Since , we need .
B6. All vectors : the -plane (the plane ).
B7. Any choices of weights work. For example (both weights zero), (weights ), (weights ).
Part C: explain and prove
C1. Prove that for vectors in .
C2. Prove that any set of vectors containing the zero vector is linearly dependent.
C3. Suppose and are independent. Prove that and are also independent.
C4. Explain in your own words why the span of any set of vectors must contain the origin, and why the line is therefore not a span.
C5. True or false, with a reason: “If is not a multiple of , and not a multiple of , then are independent.”
C1. Entry of the left side is . Entry of the right side is . These are equal by the distributive law for real numbers. Since every entry agrees, the vectors are equal.
C2. Suppose the set is . Then . The weights are not all zero, so this is a nonzero recipe for zero. By definition the set is dependent.
C3. Suppose . Rearranging gives . Since are independent, both weights must be zero: and . Adding gives , so , and then . Only the zero recipe works, so and are independent.
C4. Choosing every weight equal to zero always gives the zero vector, so is in every span. The line does not contain , because at it has . So it cannot be a span.
C5. False. Example 1.11: is not a multiple of or of , yet , so the set is dependent. Independence is a property of the whole set, not of pairs.
Part D: practise with code
Use Python with NumPy (import numpy as np).
D1. Create u = np.array([3, 1]) and v = np.array([-1, 2]). Compute u + v, 2 * u, and u - v, and check them against your hand calculations from this chapter.
D2. Write a function combo(weights, vectors) that returns the linear combination . Test it on worked example 1.4.
D3. Generate 1000 random weight pairs c1, c2 from , compute c1 * (1, 0, 1) + c2 * (0, 1, 1), and plot the points in 3-D with Matplotlib. What shape do you see, and which section explains it?
D4. NumPy can test independence with np.linalg.matrix_rank. Put vectors as columns of a matrix (np.column_stack([u, v, w])). If the rank equals the number of vectors, they are independent. Test the three sets in exercise B4.
D2. return sum(c * np.array(v) for c, v in zip(weights, vectors)).
D3. You should see a flat sheet: the plane spanned by the two vectors (section 1.5). Use ax = plt.figure().add_subplot(projection="3d") and ax.scatter(x, y, z).
D4. Expected ranks: (a) 1 of 2, dependent. (b) 3 of 3, independent. (c) 2 of 3, dependent. Rank is explained fully in LA 05 Subspaces Basis and Rank.
Where this is used
- Robot configurations. A robot’s joint angles form a vector ; a motion is a displacement (02 Geometry and Kinematics).
- Neural networks. The output of a linear layer is a linear combination of its weight columns, with the inputs as weights (05 Training Neural Policies).
- Data. If one feature in a dataset is a combination of others (for example “total = part A + part B”), the features are dependent, and a regression has no unique answer. Chapter 6 deals with this.
Next: LA 02 Dot Product Length and Angle, where we measure lengths and angles between vectors.