Skip to content
Tactiverge

Textbooks/The Mathematics of Machines/Chapter 4

4Vectors

Version 1 · Technically checked (automated checks only) · 3 source lessons · 8 practice items

Text
All chapters and search
  1. 1. Algebraic modelling
  2. 2. Functions as models
  3. 3. Trigonometry and periodic motion
  4. 4. Vectors
  5. 5. Matrices and transformations
  6. 6. Rates of change
  7. 7. Accumulation and integrals
  8. 8. Differential equations
  9. 9. Probability and uncertainty
  10. 10. Linear systems
  11. 11. Eigenvalues and stability

Introduction

Forces, velocities and displacements have a size and a direction. A vector stores both as components that you can add part by part. This chapter adds vectors, finds their length with Pythagoras, finds their direction with atan2 (which, unlike a plain inverse tangent, knows which quadrant it is in) and uses the dot product to measure how much two directions agree.

a = (3, 1)b = (1, 2)a + b = (4, 3)|a + b| = sqrt(4^2 + 3^2) = 5
Figure 4.1. Adding vectors tip to tail. On a grid, vector a = (3, 1) is drawn from the origin, then vector b = (1, 2) from the tip of a. Their sum a + b = (4, 3) goes from the origin to the final tip, with length sqrt(4^2 + 3^2) = 5.

Explanation

This chapter is built from 3 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.

4.1 Vectors: arrows you can add

A drone flies 3 m east, then 4 m north. It is 5 m from where it started, not 7. Where did the other 2 m go?

Size and direction, written as components

A vector is a quantity with a size and a direction, such as a displacement, a velocity or a force. In 2D we write it as two components, v = (vx, vy): how far along x, then how far along y, measured in some coordinate frame. The same arrow drawn anywhere on the page is the same vector; only its components matter.

Adding: tip to tail, or part by part

To add a and b, draw b starting where a ends; the sum runs from the start of a to the end of b. Algebraically that is just a + b = (ax + bx, ay + by). Subtraction works the same way: a − b is the arrow from the tip of b to the tip of a. Scaling by a number k multiplies both parts: k·a = (k·ax, k·ay).

Magnitude: Pythagoras in disguise

The components form the two short sides of a right-angled triangle, so the length (magnitude) is |v| = √(vx² + vy²). Lengths do not add like components: |a + b| ≤ |a| + |b|, with equality only when a and b point the same way. That is the drone's missing 2 m: 3 east + 4 north is (3, 4), length 5.

Common mix-ups

  • The length of a + b is |a| + |b|.
    ✓ Only when a and b point the same way. In general |a + b| is smaller, and you must add components first.
  • Moving an arrow to a different place on the page makes it a different vector.
    ✓ A vector is just its components. Position on the page doesn't matter; that is what lets you draw tip to tail.

Open the full lesson: Vectors: arrows you can add →

4.2 Which way is it pointing? Direction with atan2

Your calculator says tan⁻¹(−1 ÷ −1) = 45°. But (−1, −1) points down and to the left. Who is wrong?

Two ways to write the same arrow

Components: (x, y). Polar form: length r and direction θ, measured anticlockwise from +x. To go from polar to components: x = r cos θ, y = r sin θ. To go back: r = √(x² + y²) and θ from the inverse tangent, carefully.

Why tan⁻¹(y/x) lies

tan θ = y/x, but dividing throws away the signs: (1, 1) and (−1, −1) both give y/x = 1. So tan⁻¹ can only answer between −90° and 90°: it is right for vectors pointing rightwards (x > 0) and exactly 180° out for vectors pointing leftwards. At x = 0 it divides by zero.

atan2: the angle that knows its quadrant

atan2(y, x) takes the two parts separately, checks their signs and returns an angle in (−180°, 180°]. Add 360° to negative answers if you want 0–360°. It is in every language: Python's math.atan2, JavaScript's Math.atan2, C's atan2. Note the order: y first. Robot code uses it to turn components back into headings and joint angles.

Common mix-ups

  • tan⁻¹(y/x) always gives a vector's direction.
    ✓ Only when x > 0. Use atan2(y, x), which checks both signs.
  • atan2 takes (x, y) like a coordinate.
    ✓ It takes (y, x): the y component first. Swapping them gives the angle measured from the y axis instead.

Open the full lesson: Which way is it pointing? Direction with atan2 →

4.3 The dot product: how much do two arrows agree?

One number can tell a robot whether a target is in front of it or behind it, without a single angle being measured. How?

The recipe

a · b = ax·bx + ay·by: multiply matching parts and add. The result is a plain number (a scalar), not a vector. Order doesn't matter: a · b = b · a. And a · a = |a|², so the dot product contains Pythagoras.

What the sign says

From a · b = |a||b| cos θ: positive when the angle is under 90° (pointing roughly together), zero when perpendicular, negative when over 90° (pointing roughly apart). Lengths are never negative, so the sign comes entirely from cos θ.

Angles and shadows

Rearranged, cos θ = a · b ÷ (|a||b|), which gives the angle between any two non-zero vectors. And a · b ÷ |b| is the scalar projection of a on b: the length of a's shadow along b's direction. That is how a robot finds the part of a force that acts along a slide, or how far ahead an obstacle is along its heading.

Derivation: Why a · b = |a||b| cos θ (from the law of cosines)
  1. Draw a and b from the same point, with angle θ between them. The third side of the triangle is the vector a − b.

  2. The law of cosines for that triangle says: |a − b|² = |a|² + |b|² − 2|a||b| cos θ.

  3. Expand the left side with components: |a − b|² = (ax − bx)² + (ay − by)² = ax² + ay² + bx² + by² − 2(ax·bx + ay·by).

  4. But ax² + ay² = |a|² and bx² + by² = |b|², so the left side is |a|² + |b|² − 2(ax·bx + ay·by).

  5. Compare the two expressions: the |a|² and |b|² cancel, leaving ax·bx + ay·by = |a||b| cos θ. The component recipe and the geometric meaning are the same number.

Common mix-ups

  • The dot product of two vectors is another vector.
    ✓ It is a single number. (Multiplying each part and keeping them separate is a different operation.)
  • A negative dot product means one vector is 'negative'.
    ✓ It means the angle between them is more than 90°: they point roughly in opposite directions.

Open the full lesson: The dot product: how much do two arrows agree? →

Worked examples

Vectors: arrows you can add: example 1

A rover drives a = (5, −2) m, then b = (−1, 6) m. Where does it end up, and how far is that from the start?

Solution

a + b = (5 − 1, −2 + 6) = (4, 4) m. Distance = √(4² + 4²) = √32 ≈ 5.66 m.

Which way is it pointing? Direction with atan2: example 1

Give the direction of (4, −9) in degrees from 0 to 360.

Solution

Fourth quadrant. atan2(−9, 4) ≈ −66.0°; add 360° → 294.0°. (Here tan⁻¹ happens to agree, −66°, because x > 0.)

Which way is it pointing? Direction with atan2: example 2

A 2.5 m link points at 200°. Where is its tip?

Solution

x = 2.5 cos 200° ≈ −2.349 m, y = 2.5 sin 200° ≈ −0.855 m. Both negative: third quadrant, as expected for 200°.

The dot product: how much do two arrows agree?: example 1

Is the target at r = (−2, 5) ahead of or behind a robot facing h = (0.6, −0.8)?

Solution

h · r = 0.6 × (−2) + (−0.8) × 5 = −1.2 − 4 = −5.2. Negative: the target is behind, 5.2 m back along the heading line (h has length 1).

Interactive figures

Figure 4.2 from Vectors: arrows you can addIn 'Add tip to tail', set a = (3, 1) and b = (1, 2.5). Check the green sum against your prediction. Now make b point exactly opposite to a. What happens to a + b? Then find a b for which |a + b| = |a| + |b|.
Can't use the interactive? Read a description instead

The vector playground draws vector a in blue from the origin, vector b in orange starting at the tip of a, and their sum in dashed green from the origin to the tip of b. The readout lists every component, the sum and its length, and the same information is in the text above.

Interactive figure (online). Description: The vector playground draws vector a in blue from the origin, vector b in orange starting at the tip of a, and their sum in dashed green from the origin to the tip of b. The readout lists every component, the sum and its length, and the same information is in the text above.

Laboratory

Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.

  • Equation Lab exploration

    Equation Lab: Vectors

    Drag two vectors until their dot product is zero, and measure the angle between them.

    Open Equation Lab: Vectors →
  • Simulation OS experiment

    Simulation OS: Two-link reach

    Describe the arm's tip as the sum of two link vectors and predict its reach before running the model.

    Open Simulation OS: Two-link reach →

Guided practice

Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.

Practice 1

a = (2, −3) and b = (−5, 4). What is the x component of a + b?

Practice 2

What is the magnitude of the vector (6, 8)?

Practice 3

atan2(3, −4) is closest to which angle?

Practice 4

A target is at (−5, 12) m from a robot. How far away is it, in metres?

m

Practice 5

For which vector does tan⁻¹(y/x) give the correct direction?

Practice 6

Find a · b for a = (4, −1) and b = (2, 3).

Practice 7

Which vector is perpendicular to (2, 5)?

Practice 8

A 10 N force F = (8, 6) N pushes a cart that can only roll along the x axis. How many newtons act along the rail? (Hint: dot F with the unit vector (1, 0).)

N
  1. a = (2, −3) and b = (−5, 4). What is the x component of a + b?
  2. What is the magnitude of the vector (6, 8)?
  3. atan2(3, −4) is closest to which angle?
    • −36.9°
    • 36.9°
    • 143.1°
    • 216.9°
  4. A target is at (−5, 12) m from a robot. How far away is it, in metres? (m)
  5. For which vector does tan⁻¹(y/x) give the correct direction?
    • (−2, 5)
    • (3, −1)
    • (−1, −1)
    • (0, 4)
  6. Find a · b for a = (4, −1) and b = (2, 3).
  7. Which vector is perpendicular to (2, 5)?
    • (5, 2)
    • (−5, 2)
    • (2, −5)
    • (−2, −5)
  8. A 10 N force F = (8, 6) N pushes a cart that can only roll along the x axis. How many newtons act along the rail? (Hint: dot F with the unit vector (1, 0).) (N)

Engineering applications

  • Navigation

    A rover's heading towards a waypoint is atan2(dy, dx). Using a plain inverse tangent of dy/dx would send it the wrong way whenever the target lies behind and to the left.

  • Useful work

    The work a force does on a moving cart is the dot product of force and displacement. Only the part of the force along the motion counts, so a sideways push does no work on the cart.

Watch

Optional verified videos. Nothing loads from YouTube until you press play.

Three views of a vector (an arrow, a list of numbers, a thing you can add and scale) drawn so clearly that components stop feeling abstract.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

Splits motion into horizontal and vertical parts that run independently, the trick behind every projectile calculation.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

Why multiplying components and adding gives the same number as lengths times the cosine of the angle: the projection picture behind the dot product.

14 min 11 s · captions on YouTube · source

Nothing loads from YouTube until you press play.

  • Vectors | Chapter 1, Essence of linear algebra (3Blue1Brown)
  • Vectors and 2D Motion: Crash Course Physics #4 (CrashCourse)
  • Dot products and duality | Chapter 9, Essence of linear algebra (3Blue1Brown)

Chapter summary

  • A vector in the plane is a pair of components (x, y); vectors add component by component.
  • The magnitude is sqrt(x^2 + y^2); the direction is atan2(y, x).
  • a·b = ax·bx + ay·by = |a|·|b|·cos θ.
  • A dot product of zero means the vectors are perpendicular; a negative one means they point more than 90° apart.

Glossary

Vector addition
Vectors are added component by component: the x parts add, the y parts add, and the result is the single vector with the same effect as both.
Vector magnitude and direction
A 2D vector can be written as components (x, y) or as a magnitude and a direction angle; cosine and sine convert between the two.
Dot product
The dot product of two vectors multiplies matching components and adds them; it also equals the product of their lengths and the cosine of the angle between them.
Pythagoras' theorem
In a right-angled triangle, the square of the hypotenuse equals the sum of the squares of the other two sides.

Definitions from the Field Guide.

Project: Plan a three-leg route

A delivery robot drives three straight legs given as distances and headings. Convert each leg to components, add them, and give the straight-line distance and heading back to the start. Check the result by drawing the route to scale.

Deliverables

  • A table of legs with components
  • The total displacement, distance and heading
  • A scale drawing and the difference between drawing and calculation

Keep your work in your Engineering Journal; it stays private unless you choose to share it.

References

  • Gilbert Strang (2016). Introduction to Linear Algebra, 5th edition. Wellesley-Cambridge Press.
  • Erwin Kreyszig (2011). Advanced Engineering Mathematics, 10th edition. Wiley.

Further reading from the source lessons

Publication record

Version
1
Status
Technically checked (automated checks only)
Technical review
Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
Written by
Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
Licence
All rights reserved by the founders unless a licence is approved.
Corrections
None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.