E ExamMaster

Engineering Mathematics · Linear Algebra

Vectors in R^n

In Engineering Mathematics because features, embeddings, and parameter updates are all easier to reason about once a point is seen as a vector in a coordinate space.

Linear algebra starts by treating an object as an ordered list of numbers with a fixed coordinate meaning. This topic builds vectors as points, displacements, feature rows, and weighted scores so later matrices and ML models feel like structured arithmetic rather than notation.

  • Engineering Mathematics
  • Medium level
  • 6 concepts

1A vector is an ordered point or arrow

A vector in \mathbb{R}^n is an ordered collection of n real numbers. The order is not decoration: the first slot and the second slot play different roles, so the pair (2, -1) and the pair (-1, 2) are different vectors.

In geometry the same ordered pair can name a landing from the origin — two steps right and one step down — or name the gold arrow that makes that move. The sentence around the pair chooses the role; the numbers themselves do not.

To go from one point to another, subtract. With start P=(2,-1) and end Q=(8,3), the displacement is Q-P=(6,4). Distance is the length of that arrow; the midpoint averages each slot and is a point, not an arrow.

Animation: a coordinate plane grows a gold arrow from the origin to (2, -1), then a coral swapped landing at (-1, 2) appears and is rejected. The plane widens to show start P at (2, -1) and end Q at (8, 3) with a gold displacement arrow from P to Q labelled (6, 4). Length 2 sqrt(13) approximately 7.21 and midpoint M at (5, 1) appear on the same P to Q segment.
The same ordered pair can be a point or an arrow. Swapping slots lands somewhere else. Displacement from P to Q is Q minus P; distance is that arrow's length; the midpoint averages each slot.

Read a coordinate vector

  1. Fix axesCoordinate 1 is how far right from the origin; coordinate 2 is how far up, or down if negative. Keep that order for the whole lesson.
  2. Point viewRead (2, -1) as the landing: two steps along coordinate 1, then one step down along coordinate 2.
  3. Arrow viewThe same pair names the move from the origin to that landing. From P to Q, the displacement is Q-P, end minus start.

Distance and midpoint from coordinates

Points P = (2, -1) and Q = (8, 3) sit in the plane. Find the displacement from P to Q, its distance, and the midpoint.

  • Q - P = (8 - 2, 3 - (-1))(6, 4)
  • \|Q-P\| = \sqrt{6^2 + 4^2}\sqrt{52}
  • \sqrt{52}2\sqrt{13} \approx 7.21
  • ((2+8)/2, (-1+3)/2)(5, 1)

Pro tip. The same ordered pair can be a point or an arrow; the sentence around it tells you which role it has.

Points A = (1, 5) and B = (4, 1). What is the displacement vector from A to B?
  1. (3, -4)
  2. (5, 6)
  3. (-3, 4)
  4. (4, 1)

Displacement is B - A = (4-1, 1-5) = (3, -4). Adding coordinates or reversing the order swaps the geometric meaning.

2Add and scale component by component

Vector addition combines matching coordinates, while scalar multiplication applies the same multiplier to every coordinate. These two operations are the grammar of linear algebra — slot-by-slot bookkeeping on a list, not a new kind of arithmetic.

Picture a warehouse robot stuck mid-path at floor position x=(4, 1, 6) metres: aisle, bay, and shelf height in that fixed order. A planner chose nudge d=(2, -3, 1), but the operator wants only half of that path for a careful approach. Scale d first, then add — and keep the same slot order, or the arithmetic silently mixes aisle metres with bay metres. The same algebra later updates model features; the story here is the floor move.

Animation: aisle, bay, and height slots show warehouse robot position x=(4, 1, 6) and planned nudge d=(2, -3, 1). A half-step scales d to (1, -1.5, 0.5). The plane then grows gold x=(4, 1) with a robot at its tip, attaches teal 0.5d, and draws the resultant x+0.5d=(5, -0.5) while height updates 6 to 6.5.
Scale the planned nudge first, then add tip-to-tail. The new floor position is x + 0.5d = (5, -0.5, 6.5).

Move the robot carefully

  1. Match slotsLine up aisle, bay, and height so each nudge component sits under the coordinate it is meant to change.
  2. Scale firstMultiply every component of d by the scalar — here 0.5 for the careful half-step.
  3. Add secondAttach the scaled nudge tip-to-tail and add component by component to get the new floor position.

Warehouse robot half-step

A warehouse robot sits at floor position x=(4, 1, 6) metres (aisle, bay, height). The planner's nudge is d=(2, -3, 1). Take only half of that nudge and find the new floor position x + 0.5d.

  • 0.5d = 0.5(2, -3, 1)(1, -1.5, 0.5)
  • x + 0.5d = (4, 1, 6) + (1, -1.5, 0.5)(4+1, 1-1.5, 6+0.5)
  • (4+1, 1-1.5, 6+0.5)(5, -0.5, 6.5)

Pro tip. Scale first, then add. The same shape later updates model features; here the answer is the robot's new floor spot.

A feature row is x=(3, 0, 5) and an update direction is d=(4, -8, 0). What is x + 0.25d?
  1. (4, -2, 5)
  2. (3.25, -2, 5)
  3. (7, -8, 5)
  4. (4, -2, 5.25)

Scale first: 0.25d=(1, -2, 0). Then add: (3+1, 0-2, 5+0)=(4, -2, 5). Mixing scale and add order-by-order is a common trap.

3A dot product is a weighted sum

The dot product takes two equal-length vectors and multiplies matching coordinates before adding the products. It is not a new kind of multiplication table; it is a compact way to say weighted sum — compress two lists into one score.

Picture a plant control room waiting on one alarm number. Sensors already report readings x=(1, 4, 0.5): pressure, vibration events, and heat utilisation in that fixed order. The operator chose weights w=(2, -1, 3) — boost pressure, penalise vibration, boost heat. Pair matching slots, multiply, then add. Keep the same order, or the arithmetic silently mixes a vibration reading under a heat weight. The same multiply-add later scores an applicant or one neuron; the story here is the alarm score.

Animation: pressure, vibration, and heat slots show operator weights w=(2, -1, 3) over sensor readings x=(1, 4, 0.5). Gold pair lines lock each column, then product chips (2, -4, 1.5) appear. The three products stack into a gold alarm-score dial reading w · x = -0.5.
Pair matching sensor slots, multiply, then add. The plant alarm score is the scalar w · x = -0.5.

Compute the alarm score w\cdot x

  1. PairLine up each weight w_i only over the sensor reading x_i in the same slot — pressure with pressure, vibration with vibration, heat with heat.
  2. MultiplyCompute each matched product, preserving negative signs (the vibration penalty stays minus).
  3. AddSum the products to get one scalar alarm score — not another vector.

Control-room weighted alarm score

A plant control room has sensor readings x=(1, 4, 0.5) (pressure, vibration, heat) and operator weights w=(2, -1, 3). Compute the alarm score w\cdot x.

  • 2\cdot 12
  • -1\cdot 4-4
  • 3\cdot 0.51.5
  • 2 + (-4) + 1.5-0.5

Pro tip. Pair, multiply, then add. The same arithmetic later scores an applicant or one neuron; here the answer is the plant alarm number -0.5.

Coding lab. Compute a vector score with NumPy runs in the app, with checks on your output.

Weights w=(1, 2, -1) score features x=(3, 0, 2). What is w \cdot x?
  1. 1
  2. 5
  3. 3
  4. -1

1\cdot3 + 2\cdot0 + (-1)\cdot2 = 3 + 0 - 2 = 1. Pairing wrong coordinates or dropping the minus sign both break the score.

4Projection finds the course shadow; cosine reads the angle

A nav mission desk needs the course shadow of planned heading u along reference heading v. Projection is that shadow: \mathrm{proj}_v(u)=((u\cdot v)/(\|v\|^2))v. Speak the pieces: the numerator is the dot product, the denominator is length squared — keep it squared — and the last step multiplies that one scalar by every slot of v. The foot F from the origin is exactly that projection vector; the residual u_\perp=u-\mathrm{proj}_v(u) is the leftover from F to the tip of u. Derive the foot from the scalar times v; never guess it from a sketch. The same formula works in \mathbb{R}^n when no honest picture of the drop exists.

Once that adjacent shadow is known, cosine keeps only the angle. Adjacent is \|\mathrm{proj}\|, hypotenuse is \|u\|, so \cos\theta=\|\mathrm{proj}\|/\|u\|. The algebraic twin (u\cdot v)/(\|u\|\|v\|) returns the same number. For u=(3,4) and v=(4,0), the desk gets \cos\theta=0.6 and \theta\approx53.1^\circ — partial alignment: closer than perpendicular, not the same heading. Raw needle length is not alignment; cosine divides size out on purpose.

Animation: mission-desk chips show planned course u=(3, 4) and reference heading v=(4, 0). Ledger rows resolve u·v=12, |v|²=16, scalar=3/4, then scale to gold proj=F=(3, 0) and coral residual (0, 4). A brief confirm plane draws only after the algebra. Cosine then reads |proj|/|u|=3/5=0.6 and the twin (u·v)/(|u||v|)=0.6 with θ≈53.1°.
Derive proj_v(u)=((u·v)/(|v|²))v first — foot F=(3, 0) and residual (0, 4) — then read cos θ = |proj|/|u| = 0.6 (θ≈53.1°).

Project by algebra, then read cosine

  1. Dot and scaleCompute u\cdot v and \|v\|^2, form the scalar (u\cdot v)/(\|v\|^2), then multiply by v to get \mathrm{proj}_v(u)=F.
  2. ResidualSubtract u_\perp=u-\mathrm{proj}_v(u). In 2D you may draw afterward; in higher dimensions keep the same formula without a picture.
  3. CosineRead \cos\theta=\|\mathrm{proj}\|/\|u\| or the twin (u\cdot v)/(\|u\|\|v\|) — same alignment number.

Mission-desk projection then cosine

A nav mission desk has planned course u=(3,4) and reference heading v=(4,0). Derive \mathrm{proj}_v(u) and u_\perp by algebra, then find \cos\theta and \theta.

  • u\cdot v = 3\cdot4 + 4\cdot012
  • \|v\|^2 = 4^2+0^216
  • (u\cdot v)/(\|v\|^2)=12/163/4
  • (3/4)\cdot(4,0)\mathrm{proj}=F=(3,0)
  • u-\mathrm{proj}=(3,4)-(3,0)u_\perp=(0,4)
  • \|\mathrm{proj}\|/\|u\|=3/5\cos\theta=0.6
  • (u\cdot v)/(\|u\|\|v\|)=12/(5\cdot4)0.6
  • \theta=\cos^{-1}(0.6)\approx 53.1^\circ

Pro tip. Algebra first, picture second. Cosine 0.6 is partial alignment: closer than perpendicular, not the same heading.

For u=(6, 8) and v=(0, 5), which statement about \cos\theta = (u\cdot v)/(\|u\|\|v\|) is correct?
  1. u\cdot v=40, \|u\|=10, \|v\|=5, so \cos\theta=0.8
  2. u\cdot v=30, so \cos\theta=0.6
  3. \|u\|=14, so \cos\theta uses that length
  4. Cosine needs only the larger vector's length

u\cdot v=6\cdot0+8\cdot5=40, \|u\|=\sqrt{36+64}=10, \|v\|=5, so \cos\theta=40/50=0.8.

5Basis vectors give coordinates their meaning

A basis is the set of reference directions used to describe vectors. Coordinates are the amounts of those directions. In the standard basis of \mathbb{R}^3, those directions are e_1=(1,0,0), e_2=(0,1,0), and e_3=(0,0,1) — each e_i turns on exactly one coordinate and leaves the others at zero.

Picture a CNC machine bed stuck on a destination ticket p=(4,-2,7). CNC means a computer-guided cutting or milling machine — like a computer-guided mill or a 3D-printer bed. Three numbers sit on the job sheet, but they are useless until the bed's reference directions are named. Fix the standard axes first; then the ticket means four of e_1, minus two of e_2, and seven of e_3. Scale each basis vector, add the three pure-axis pieces, and the sum recovers p. Change the basis and the same written list lands somewhere else on the bed.

Animation: a CNC destination ticket shows p=(4, -2, 7) beside unnamed axis stubs. Axes name in order as e1=(1, 0, 0), e2=(0, 1, 0), e3=(0, 0, 1), then amount chips read 4 of e1, -2 of e2, and 7 of e3. Scale chips build 4e1=(4, 0, 0), -2e2=(0, -2, 0), and 7e3=(0, 0, 7), then sum to p with the expansion p = 4e1 - 2e2 + 7e3.
Name the standard axes first, then scale each basis vector and add. The CNC ticket recovers as p = 4e1 - 2e2 + 7e3 = (4, -2, 7).

Rebuild the CNC destination from the standard basis

  1. Name axesWrite the standard basis: e_1=(1,0,0), e_2=(0,1,0), e_3=(0,0,1). Until those directions are fixed, the ticket is only a list.
  2. Read amountsIn that basis, p=(4,-2,7) means four copies of e_1, negative two of e_2, and seven of e_3.
  3. Scale then addScale each basis vector, then add the pure-axis pieces: 4e_1=(4,0,0), -2e_2=(0,-2,0), 7e_3=(0,0,7), and their sum is p.
Standard basis in \mathbb{R}^3
Basis vectorCoordinatesMeaning
e_1(1,0,0)first-axis direction (along the bed)
e_2(0,1,0)second-axis direction (across the bed)
e_3(0,0,1)third-axis direction (up from the bed)

CNC destination in the standard basis

A CNC machine bed (computer-guided mill / 3D-printer bed) receives destination ticket p=(4,-2,7). Write p as a combination of the standard basis vectors e_1,e_2,e_3.

  • 4e_1(4,0,0)
  • -2e_2(0,-2,0)
  • 7e_3(0,0,7)
  • (4,0,0)+(0,-2,0)+(0,0,7)(4,-2,7)=p

Pro tip. Axes first, list second. Changing the basis changes what the same coordinate list means — the landing on the bed moves even though the written numbers look identical.

Write p=(5, -3, 2) using the standard basis e_1,e_2,e_3. Which expansion is correct?
  1. 5e_1 - 3e_2 + 2e_3
  2. 5e_1 + 3e_2 + 2e_3
  3. -3e_1 + 5e_2 + 2e_3
  4. 5e_3 - 3e_2 + 2e_1

Each coordinate multiplies the matching basis vector: p=5e_1+(-3)e_2+2e_3. Swapping signs or basis slots changes the point.

6One data row is a vector

Open a study-log spreadsheet. One student row has columns intercept, hours studied, and past score filled as 1, 6, and 0.8. Those three cells in a fixed column order are already a feature list — and that list is a vector in \mathbb{R}^3. With n feature columns, the same reading is a vector in \mathbb{R}^n\mathbb{R}^n means the space of fixed-order lists of n real numbers.

Column order is coordinate order: slot one becomes x_1, slot two becomes x_2, and so on. Pack the readings as x=(1,6,0.8). Once a row is a vector, earlier operations become machine-learning (ML) operations: add an update, score with a dot product, or compare rows by distance or direction. Swap the column order and the same digits become a different vector, so every later weight that expected intercept first silently mis-fires.

Animation: a study-log spreadsheet opens with headers intercept, hours studied, and past score, then fills the student row as 1, 6, and 0.8 with slot labels. Pack chips build x1=1, x2=6, and x3=0.8 into the gold dial x=(1, 6, 0.8), named as a vector in R^3 and generalised to n columns as R^n. A trap board then contrasts (1, 6, 0.8) with swapped (6, 0.8, 1).
Column order is coordinate order. Pack the study-log row as x=(1, 6, 0.8) in R^3 — the same idea is a vector in R^n — and keep the order fixed or later weights mis-fire.

Build the feature vector from the study-log row

  1. Fix columnsRead headers in order: intercept, hours studied, past score. Column order is coordinate order — whatever sits in slot one becomes x_1.
  2. Read slotsFrom the same row: x_1=1 (intercept), x_2=6 (hours studied), x_3=0.8 (past score).
  3. Pack and nameWrite x=(x_1,x_2,x_3), here (1,6,0.8) — a vector in \mathbb{R}^3. With n columns the same idea is a vector in \mathbb{R}^n. Keep the order fixed or later weights mis-fire.
Feature row
intercepthours studiedpast score
160.8

Build the feature vector from a table row

A model uses columns in this order: intercept, hours studied, past score. For the study-log row shown as 1, 6, 0.8, build the feature vector x.

  • Coordinate 1: interceptx_1 = 1
  • Coordinate 2: hours studiedx_2 = 6
  • Coordinate 3: past scorex_3 = 0.8
  • x=(x_1,x_2,x_3)(1,6,0.8)

Pro tip. The intercept is just another coordinate after you decide to include it; every later weight vector must use this exact same order. Swapping slots reassigns weights without changing the written digits.

A model uses columns in order: intercept, temperature, wind. For intercept =1, temperature =22, wind =7, which feature vector is correct?
  1. (1, 22, 7)
  2. (22, 7, 1)
  3. (1, 7, 22)
  4. (22, 1, 7)

Feature order is part of the vector. Putting intercept last or swapping temperature and wind silently reassigns weights.

Notes

  • A vector in R^n is an ordered n-tuple, so each coordinate has meaning only after the basis, order, and units are fixed.
  • Addition and scalar multiplication act component by component, which is why vectors can represent geometry, feature updates, and parameter changes.
  • The dot product turns two equal-length vectors into one weighted sum; in ML this is the core multiply-add behind a linear score.

Formulas

  • If x, y in R^n, then x + y = (x_1 + y_1, ..., x_n + y_n).
  • If c is a scalar, then c x = (c x_1, ..., c x_n).
  • The dot product is w . x = w_1 x_1 + ... + w_n x_n.
  • For nonzero u and v, cos theta = (u . v) / (||u|| ||v||).

Exam traps & shortcuts

  • Always ask what each coordinate means before interpreting distance or direction.
  • A dot product only pairs matching coordinates; changing column order changes the score.

Recap

Vectors are the shared language behind geometry and data rows.

Object
A vector is an ordered numerical object whose coordinates mean something only after the basis and column order are fixed.
Operations
Addition and scalar multiplication work coordinate by coordinate, so feature updates and geometric displacements use the same arithmetic.
Score
A dot product is a weighted sum: pair matching slots, multiply, then add — the plant alarm w\cdot x is the same shape as a linear model score.
Geometry
Projection finds the course shadow by algebra; cosine then reads the angle from that adjacent length or from the normalized dot product.

Practise Vectors in R^n

Reading is free and needs no account. Practice, mocks and progress live in the app.

  • A 5-question practice set that ends the chapter
  • 6 quick checks with worked explanations
  • Timed mocks scored with the real marking scheme
  • Readiness tracked per topic, kept on your device
Continue with Google — freeNo card, no trial. Works offline once installed.