determin.ant
01-vectors / 1.3

Module 1: Vectors

Scalar Multiplication

Where you'll see this: adjusting the speed of a moving object (scale its velocity vector), zooming a camera (scale the view direction), normalising audio volume (scale a sound vector), or adjusting the learning rate of a gradient in machine learning (scale the gradient vector).

You can add vectors together. But you can also do something simpler: take a single vector and scale it — make it longer, shorter, or flip it around. That operation is called scalar multiplication.

What is a scalar?

A scalar is just a plain number — no direction, no components, just a magnitude. The number 3 is a scalar. So is −0.5, or π. When you multiply a vector by a scalar, you're resizing the arrow.

What it does to the arrow

Positive scalar — stretch or shrink

Multiplying by 2 doubles the length. Multiplying by 0.5 halves it. The direction stays exactly the same — the arrow just gets longer or shorter.

Negative scalar — flip and scale

Multiplying by −1 reverses the direction. The arrow points the opposite way, but has the same length. Multiplying by −2 doubles the length and flips the direction.

Zero — the arrow disappears

Multiplying by 0 gives the zero vector [0, 0][0,\ 0]. No length, no direction — just a point sitting at the origin. It's the additive identity: add it to anything and nothing changes.

The algebra

The rule is simple: multiply each component by the scalar.

s[x, y]=[sx, sy]s \cdot [x,\ y] = [sx,\ sy]

So 3[2, 1]=[6, 3]3 \cdot [2,\ 1] = [6,\ 3]. The vector triples in length and keeps pointing the same way.

Length scales by the absolute value

If the original vector has length v\|\mathbf{v}\|, then the scaled vector has length sv|s| \cdot \|\mathbf{v}\|. The absolute value of the scalar tells you how much the length changes; the sign tells you whether the direction flips.

Try dragging the slider to exactly −1. The length readout stays the same, but the arrow reverses. That's the geometric meaning of negation.

In code

import numpy as np

v = np.array([2, 2])

print(3 * v)     # [ 6  6]  — stretch
print(-1 * v)    # [-2 -2]  — flip
print(0.5 * v)   # [1. 1.]  — shrink

NumPy broadcasts scalar multiplication across every element. Same rule, same result — and it works on vectors of any length.

Why this matters

Scalar multiplication is one half of a bigger idea coming up shortly: linear combinations. When you can both scale vectors and add them together, you can reach any point in space — or describe complex motions as weighted sums of simpler ones.

Vector AdditionLinear Combinations
move the slider — drag the vector to change its direction
-6-6-5-5-4-4-3-3-2-2-1-11122334455661.5vv
scalar1.5
−303
1.5 × [2, 2] = [3, 3]
|v| = 2.83|1.5v| = 4.24
stretches