TExcelTAD
Home › Linear Algebra & Matrix Theory › Scalar Multiplication

Scalar Multiplication

Multiplying a vector by a number, a scalar, multiplies every component by that number. Geometrically it stretches or shrinks the arrow, and a negative scalar also flips it around. Together with addition, this is the second basic operation of linear algebra.

The definition

For a scalar cc and a vector v=(v1,…,vn)\mathbf{v} = (v_1, \ldots, v_n):

c⋅v=(c⋅v1,c⋅v2,…,c⋅vn)c \cdot \mathbf{v} = (c \cdot v_1, c \cdot v_2, \ldots, c \cdot v_n)
3⋅(2,−1,4)=(6,−3,12)−12⋅(2,−1,4)=(−1,12,−2)\begin{aligned} 3 \cdot (2, -1, 4) &= (6, -3, 12) \\ -\tfrac{1}{2} \cdot (2, -1, 4) &= (-1, \tfrac{1}{2}, -2) \end{aligned}

"Scalar" just means "a single number" (from the field you work over, usually R\mathbb{R}). The name comes from the fact that it scales vectors.

The geometry

Scalar cc Effect on the arrow
c>1c > 1 same direction, longer
0<c<10 < c < 1 same direction, shorter
c=1c = 1 unchanged
c=0c = 0 the zero vector
c=−1c = -1 same length, opposite direction
c<0c < 0 opposite direction, stretched by ∣c∣\lvert c \rvert

The length of c⋅vc \cdot \mathbf{v} is ∣c∣\lvert c \rvert times the length of v\mathbf{v} (see Length of a Vector).

Two non-zero vectors are parallel (or collinear) if one is a scalar multiple of the other. (2,−6)(2, -6) and (−1,3)(-1, 3) are parallel, since (2,−6)=−2⋅(−1,3)(2, -6) = -2 \cdot (-1, 3); they point in opposite directions.

python · try it yourself
from fractions import Fraction as F

def parallel_factor(u, v):
    """Return c with u = c*v, or None if u is not a multiple of v (v non-zero)."""
    c = None
    for a, b in zip(u, v):
        if b == 0:
            if a != 0:
                return None
            continue
        r = F(a, b)
        if c is None:
            c = r
        elif r != c:
            return None
    return c

print(parallel_factor((2, -6), (-1, 3)))
print(parallel_factor((4, 0, 6), (2, 0, 3)))
print(parallel_factor((1, 2, 3), (2, 4, 7)))
-2
2
None

The rules

For all vectors u,v\mathbf{u}, \mathbf{v} and scalars c,dc, d:

Rule Formula
distributive over vector addition c⋅(u+v)=c⋅u+c⋅vc \cdot (\mathbf{u} + \mathbf{v}) = c \cdot \mathbf{u} + c \cdot \mathbf{v}
distributive over scalar addition (c+d)⋅v=c⋅v+d⋅v(c + d) \cdot \mathbf{v} = c \cdot \mathbf{v} + d \cdot \mathbf{v}
associative c⋅(d⋅v)=(c⋅d)⋅vc \cdot (d \cdot \mathbf{v}) = (c \cdot d) \cdot \mathbf{v}
identity 1⋅v=v1 \cdot \mathbf{v} = \mathbf{v}

Consequences: 0⋅v=00 \cdot \mathbf{v} = \mathbf{0} and (−1)⋅v=−v(-1) \cdot \mathbf{v} = -\mathbf{v}. For example, 0⋅v=(0+0)⋅v=0⋅v+0⋅v0 \cdot \mathbf{v} = (0 + 0) \cdot \mathbf{v} = 0 \cdot \mathbf{v} + 0 \cdot \mathbf{v}, and subtracting 0⋅v0 \cdot \mathbf{v} from both sides gives 0=0⋅v\mathbf{0} = 0 \cdot \mathbf{v}.

python · try it yourself
from sympy import Matrix, symbols, expand

c, d = symbols("c d")
u = Matrix(symbols("u1:4"))
v = Matrix(symbols("v1:4"))

print((c * (u + v) - (c * u + c * v)).expand() == Matrix([0, 0, 0]))
print(((c + d) * v - (c * v + d * v)).expand() == Matrix([0, 0, 0]))
print(c * (d * v) == (c * d) * v)
print(list(0 * v), list(-1 * v))
True
True
True
[0, 0, 0] [-v1, -v2, -v3]

In NumPy: broadcasting

NumPy multiplies an array by a number component-wise, and it can scale many vectors at once:

python · try it yourself
import numpy as np

v = np.array([2.0, -1.0, 4.0])
print("3v   =", 3 * v)
print("-v/2 =", -v / 2)

# scale each row (a velocity) by its own factor
velocities = np.array([[1.0, 0.0], [0.0, 2.0], [3.0, 4.0]])
factors = np.array([10.0, 0.5, -1.0])
print(factors[:, None] * velocities)

# make a colour 40% darker (RGB values in 0..1)
orange = np.array([1.0, 0.6, 0.2])
print("darker:", np.round(0.6 * orange, 2))
3v   = [ 6. -3. 12.]
-v/2 = [-1.   0.5 -2. ]
[[10.  0.]
 [ 0.  1.]
 [-3. -4.]]
darker: [0.6  0.36 0.12]

factors[:, None] turns the factors into a column of shape (3, 1), so each row is scaled by its own number. Broadcasting is explained in NumPy Broadcasting.

In software

  • Games: speed⋅direction\text{speed} \cdot \text{direction} gives a velocity; velocity⋅Δt\text{velocity} \cdot \Delta t gives the distance moved in one frame. Reversing a bouncing ball's velocity component is multiplication by −1-1 (or by −0.8-0.8 for a ball that loses energy).
  • ML: the learning rate η\eta scales the gradient in each update, w←w−η⋅∇Lw \leftarrow w - \eta \cdot \nabla L. Too large a scalar overshoots, too small barely moves.
  • Graphics: scaling an RGB colour by a factor dims or brightens it; scaling a direction to length 1 is called normalizing (next lessons).

Exercises

Exercise 1: Compute

Compute −3⋅(1,0,−2)+2⋅(4,1,−1)-3 \cdot (1, 0, -2) + 2 \cdot (4, 1, -1).

Answer

(5, 2, 4).

Solution
−3⋅(1,0,−2)=(−3,0,6)2⋅(4,1,−1)=(8,2,−2)sum=(5,2,4)\begin{aligned} -3 \cdot (1, 0, -2) &= (-3, 0, 6) \\ 2 \cdot (4, 1, -1) &= (8, 2, -2) \\ \text{sum} &= (5, 2, 4) \end{aligned}

Exercise 2: Parallel?

Which pairs are parallel? (a) (3,−6,9)(3, -6, 9) and (−1,2,−3)(-1, 2, -3); (b) (1,2)(1, 2) and (2,1)(2, 1); (c) (0,5,0)(0, 5, 0) and (0,−0.5,0)(0, -0.5, 0).

Answer

(a) and (c).

Solution
(a) (3,−6,9)=−3⋅(−1,2,−3)parallel (opposite directions)(b) 12≠21not parallel(c) (0,5,0)=−10⋅(0,−0.5,0)parallel\begin{aligned} &\text{(a) } (3, -6, 9) = -3 \cdot (-1, 2, -3) && \text{parallel (opposite directions)} \\ &\text{(b) } \tfrac{1}{2} \ne \tfrac{2}{1} && \text{not parallel} \\ &\text{(c) } (0, 5, 0) = -10 \cdot (0, -0.5, 0) && \text{parallel} \end{aligned}

Exercise 3: Solve for the scalar

Find cc such that c⋅(2,−1)+(1,3)=(−5,6)c \cdot (2, -1) + (1, 3) = (-5, 6).

Answer

c=−3c = -3.

Solution
c⋅(2,−1)=(−6,3)first component: 2c=−6→c=−3;second: −c=3→c=−3 ✓ (both must agree)\begin{aligned} c \cdot (2, -1) &= (-6, 3) \\ &\text{first component: } 2c = -6 \to c = -3; \quad \text{second: } -c = 3 \to c = -3 \ \checkmark \ \text{(both must agree)} \end{aligned}

Exercise 4: Bounce with energy loss (code)

A ball has velocity (4,−10)(4, -10). When it hits the floor, the vertical component is multiplied by −0.7-0.7. Simulate 3 bounces (ignore gravity between bounces) and print the velocity after each.

Answer

(4,7)(4, 7), (4,−4.9)(4, -4.9), (4,3.43)(4, 3.43).

Solution

Only the y-component is scaled, which is multiplication by the vector (1,−0.7)(1, -0.7) component-wise, not a scalar multiplication of the whole vector. (Without gravity, the "bounces" just flip the sign each time, which is fine for this exercise.)

python · try it yourself
import numpy as np

v = np.array([4.0, -10.0])
for bounce in range(3):
    v = v * np.array([1.0, -0.7])
    print(bounce + 1, np.round(v, 2))
1 [4. 7.]
2 [ 4.  -4.9]
3 [4.   3.43]

Test yourself

What is −2⋅(3,−1,0)-2 \cdot (3, -1, 0)?

  1. (−6,2,0)(-6, 2, 0)
  2. (−6,−2,0)(-6, -2, 0)
  3. (1,−3,−2)(1, -3, -2)
  4. (6,−2,0)(6, -2, 0)

If c⋅v=0c \cdot \mathbf{v} = \mathbf{0} and v≠0\mathbf{v} \ne \mathbf{0}, what must cc be?

  1. 1
  2. -1
  3. 0
  4. Any number

What does multiplying a vector by −0.5-0.5 do geometrically?

  1. Rotates it by 90°
  2. Halves its length and reverses its direction
  3. Doubles its length
  4. Leaves it unchanged