# vectors

> arrows you add and stretch, and the dot product that gives length, angle and projection.

source: https://learning.anthnydas.com/math/vectors/

## tl;dr

a vector is an arrow, a length and a direction, and it's also two numbers, how far across and how far up. add arrows head to tail, stretch them with a number, and the dot product turns two arrows into one number that says how much they point the same way.

- **add:** (x, y) + (u, v) = (x + u, y + v) (head to tail on the grid, part by part on paper)
- **scale:** k·(x, y) = (kx, ky) (k < 0 flips the arrow)
- **length:** |a| = √(x² + y²) (pythagoras on the two parts)
- **dot product:** xu + yv = |a| |b| cos θ (0 means perpendicular. negative means past 90°)
- **projection:** (a · b / |b|²) b (a's shadow on b, a · b / |b| long)
- **signed area:** xv − yu (the parallelogram a and b span. the determinant on the matrices page)
- **|a + b|:** ≤ |a| + |b| (lengths don't add unless the arrows point the same way)
- **the zero vector:** (0, 0) (length 0 and no direction. normalizing it divides by 0)
- **reach for it:** a position, a velocity, a force: anything with a size and a direction, how much two things point the same way: lighting, similarity, work, the columns of a matrix, on the next page

## the idea

a vector is an arrow. it has a length and a direction, and that's all: slide it anywhere on the page and it's the same vector. a velocity is one, a force is one, the step from one point to another is one. to work with it on paper, write down how far it goes across and how far up: $\mathbf a = (3, 1)$ goes 3 to the right and 1 up. the two numbers are its components, and the arrow and the pair of numbers are the same thing seen two ways.

everything on this page is one of a few moves on arrows: add two, stretch one by a number, measure one, and multiply two into a single number, the dot product. the first three are in the movie.

> **interactive figure:** an animation on a grid from x = −3.5 to 6.5 and y = −3.5 to 4.5. first a = (3, 1) in cyan grows from the origin, with its two parts drawn under it: 3 across, 1 up, and the readout |a| = √10 ≈ 3.16. then b = (1, 3) in amber appears at the origin and slides to the tip of a, and a + b = (4, 4) is drawn in white from the origin, 4√2 ≈ 5.66 long. third, b from the origin and a copy of a from its tip close a parallelogram with area 3·3 − 1·1 = 8. fourth, a alone is stretched to 2a = (6, 2) and then shrunk through 0 to −a = (−3, −1), along a dotted line through the origin. fifth, −b hangs off the tip of a and lands on a − b = (2, −2), the arrow from the tip of b to the tip of a. last, 2a − b: a stretched to (6, 2), −b from its tip, and the white result (5, −1).

$\mathbf a = (3, 1)$: an arrow from the origin, 3 across and 1 up. the two numbers are its components. its length comes from pythagoras on them: $|\mathbf a| = \sqrt{3^2 + 1^2} = \sqrt{10} \approx 3.16$.

to add $\mathbf b = (1, 3)$, put its tail on the tip of $\mathbf a$. the arrow from the start to the new tip is $\mathbf a + \mathbf b$. part by part it's $(3 + 1,\ 1 + 3) = (4, 4)$. its length is $4\sqrt 2 \approx 5.66$, less than $|\mathbf a| + |\mathbf b| \approx 6.32$: the route bends, so the straight arrow is shorter.

$\mathbf b$ first, then $\mathbf a$, lands on the same tip: $\mathbf a + \mathbf b = \mathbf b + \mathbf a$. the two routes close a parallelogram, and its area is $3 \cdot 3 - 1 \cdot 1 = 8$. that number comes back as the determinant on the [matrices page](/math/matrices/#the-determinant).

a number stretches an arrow: $2\mathbf a = (6, 2)$ is twice as long and points the same way. a negative number flips it: $-\mathbf a = (-3, -1)$. every multiple $k\mathbf a$ lies on the dotted line through the origin, the span of $\mathbf a$.

subtracting is adding the flipped arrow: $\mathbf a - \mathbf b = \mathbf a + (-\mathbf b) = (3 - 1,\ 1 - 3) = (2, -2)$. it's also the arrow from the tip of $\mathbf b$ to the tip of $\mathbf a$: the step that takes you from $\mathbf b$ to $\mathbf a$.

stretch each, then add: $2\mathbf a - \mathbf b = (6, 2) + (-1, -3) = (5, -1)$. that's a linear combination, and since $\mathbf a$ and $\mathbf b$ aren't parallel, some $s\mathbf a + t\mathbf b$ reaches every point of the plane.

## explore

drag the tips. the white arrow is $\mathbf a + \mathbf b$, and the dashed copy of $\mathbf b$ hanging off the tip of $\mathbf a$ is the head-to-tail route to it. the gray bar on the line of $\mathbf b$ is the shadow of $\mathbf a$ on $\mathbf b$: the part of $\mathbf a$ that points along $\mathbf b$. watch the dot product as the angle passes 90°.

> **interactive figure:** a = (3, 1) in cyan and b = (1, 3) in amber from the origin, on a grid from −6 to 6 each way, with a + b = (4, 4) in white, a dashed copy of b from the tip of a, the angle between them marked with an arc, and the shadow of a on b as a gray bar along b's line. drag either tip on a half-unit grid, or tab to it and use the arrow keys, and the readout follows: |a| = |b| = √10 ≈ 3.16 to start, |a + b| = √32 ≈ 5.66, a · b = 3·1 + 1·3 = 6, the same as |a| |b| cos θ = 3.16 · 3.16 · 0.60, θ ≈ 53.1°, the shadow (0.6, 1.8), 1.90 long, and the signed area 3·3 − 1·1 = 8. when the tips are at right angles a · b reads 0 and the shadow is a point; past 90° it goes negative and the shadow falls behind b's tail. a tip on the origin is the zero vector: no direction, no angle.

## try it

> **interactive figure:** a practice exercise with a small grid under each question: the sum of two vectors, a combination like 2a − b, the length of a vector with a whole length like (3, 4), whether a dot product is positive, zero or negative, and which of four vectors is perpendicular to a given one. after an answer the grid draws it: the result in white, the two parts of a length, or the angle between the arrows.

## the rules

### an arrow, or two numbers

$$
\mathbf a = (a_x, a_y) = a_x\,\mathbf i + a_y\,\mathbf j
$$

a vector is written as its components: how far it goes along $x$ and along $y$. $\mathbf i = (1, 0)$ and $\mathbf j = (0, 1)$ are the arrows of length 1 along the two axes, so the components are also the amounts of $\mathbf i$ and $\mathbf j$ in the vector: $(3, 1) = 3\mathbf i + \mathbf j$. a 3d vector has a third component, $z$, and everything below works the same with one more term; the [cg fundamentals page](/graphics/cg-fundamentals/#vectors--matrices) does the 3d versions, with code. the arrow has no fixed place: $(3, 1)$ drawn from the origin and $(3, 1)$ drawn from $(2, 2)$ are the same vector. a point is also written as two numbers, but it's a place, not a step; the pitfalls below come back to that.

### adding and subtracting

$$
\begin{gathered}
\mathbf a + \mathbf b = (a_x + b_x,\ a_y + b_y) \\[6pt]
\mathbf a - \mathbf b = (a_x - b_x,\ a_y - b_y)
\end{gathered}
$$

head to tail: put the tail of $\mathbf b$ on the tip of $\mathbf a$, and $\mathbf a + \mathbf b$ runs from the tail of $\mathbf a$ to the tip of $\mathbf b$. part by part: the $x$ steps add and the $y$ steps add, because walking across and walking up are separate walks. the order doesn't matter, and the two orders close a parallelogram whose diagonal is the sum. $\mathbf a - \mathbf b$ is the arrow from the tip of $\mathbf b$ to the tip of $\mathbf a$: the step that takes you from $\mathbf b$ to $\mathbf a$, so $\mathbf b + (\mathbf a - \mathbf b) = \mathbf a$. it's the same as $\mathbf a + (-\mathbf b)$: add the flipped arrow.

### scaling

$$
k\mathbf a = (k a_x,\ k a_y)
$$

a plain number stretches an arrow, which is why numbers are called scalars next to vectors. $2\mathbf a$ is twice as long, $0.5\mathbf a$ half as long, $-\mathbf a$ the same length the other way, and $0\mathbf a$ is the zero vector. the direction never changes except to flip. two vectors are parallel when one is a multiple of the other, and all the multiples of one arrow lie on one line through the origin.

### length

$$
|\mathbf a| = \sqrt{a_x^2 + a_y^2}
$$

the components are the two legs of a right triangle and the arrow is its hypotenuse, so pythagoras gives the length: $|(3, 4)| = 5$ and $|(3, 1)| = \sqrt{10} \approx 3.16$. scaling scales it, $|k\mathbf a| = |k|\,|\mathbf a|$. the zero vector has length 0 and no direction: it's the one arrow that doesn't point. in code the length is `Math.hypot(x, y)`, which gives exactly 5 for `Math.hypot(3, 4)`.

### unit vectors

$$
\hat{\mathbf a} = \frac{\mathbf a}{|\mathbf a|}
$$

divide an arrow by its own length and it's 1 long, the same way: a direction with the size taken out. $(3, 4) / 5 = (0.6, 0.8)$, and $0.6^2 + 0.8^2 = 1$. a unit vector times a length is an arrow of that length in that direction, which is how a speed and a heading become a velocity. the zero vector can't be normalized: $0 / 0$.

### linear combinations and span

$$
s\mathbf a + t\mathbf b
$$

stretch each arrow by its own number and add: a linear combination. everything you can reach that way is the span. one arrow spans a line. two arrows that aren't parallel span the whole plane: for any target there is exactly one pair $s, t$ that lands on it, and finding the pair is solving two equations in two unknowns, the [linear systems page](/math/linear-systems/). two parallel arrows span only a line: the second adds no new direction. $\mathbf i$ and $\mathbf j$ are the simplest pair, and with them the coefficients are the coordinates, $(x, y) = x\mathbf i + y\mathbf j$. any other pair that isn't parallel works as a basis too, with different numbers for the same point.

> **interactive figure:** two arrows from the origin on a grid from −6.5 to 6.5 across and −4.5 to 4.5 up, u = (2, 1) in cyan and v = (−1, 1) in amber to start, two sliders s and t from −2 to 2 in half steps, s·u dashed in cyan, t·v dashed in amber from its tip, their sum s·u + t·v in white, and a hollow target at (1, 2). it opens at s = 1, t = 0, on u itself; s = 1 and t = 1 land on the target: 1·(2, 1) + 1·(−1, 1) = (1, 2). a row of buttons swaps the pair: i = (1, 0) and j = (0, 1), where s = 1 and t = 2 reach it and the two numbers are the coordinates, or u with w = (−1, −0.5), parallel to it, where every combination stays on a dotted line through the origin and the target is out of reach.

### the dot product

$$
\mathbf a \cdot \mathbf b = a_x b_x + a_y b_y = |\mathbf a|\,|\mathbf b|\cos\theta
$$

two vectors in, one number out. on paper: multiply matching parts and add. in the picture: the two lengths times the cosine of the angle between them. the two forms agree, which the key idea below shows, and each has its job: the first is what you compute, the second is what it means. $\cos\theta$ is 1 when the arrows point the same way, 0 at a right angle and $-1$ when they're opposite, so the sign of $\mathbf a \cdot \mathbf b$ says which side of 90° the angle is on, with no trig at all. $\mathbf a \cdot \mathbf a = |\mathbf a|^2$, so the dot product holds the length too. it's symmetric, $\mathbf a \cdot \mathbf b = \mathbf b \cdot \mathbf a$, and it spreads over sums, $\mathbf a \cdot (\mathbf b + \mathbf c) = \mathbf a \cdot \mathbf b + \mathbf a \cdot \mathbf c$, both of which you can read off the component form.

### perpendicular

$$
\mathbf a \cdot \mathbf b = 0 \iff \mathbf a \perp \mathbf b
$$

a dot product of 0 means $\cos\theta = 0$, a right angle, unless one of the arrows is the zero vector. in 2d a perpendicular is one move away: swap the components and flip one sign. $(-a_y, a_x)$ is $\mathbf a$ turned a quarter turn counter-clockwise, and $a_x(-a_y) + a_y a_x = 0$. for $(2, 3)$ that's $(-3, 2)$.

### projection

$$
\begin{gathered}
\operatorname{proj}_{\mathbf b}\mathbf a = \frac{\mathbf a \cdot \mathbf b}{\mathbf b \cdot \mathbf b}\,\mathbf b \\[6pt]
\text{its length: } \frac{\mathbf a \cdot \mathbf b}{|\mathbf b|} = |\mathbf a|\cos\theta
\end{gathered}
$$

drop a perpendicular from the tip of $\mathbf a$ onto the line of $\mathbf b$. where it lands is the shadow of $\mathbf a$ on $\mathbf b$: the part of $\mathbf a$ that points along $\mathbf b$. its length is $|\mathbf a|\cos\theta$, the side next to $\theta$ in a right triangle whose hypotenuse is $|\mathbf a|$, and by the second form of the dot product that's $\mathbf a \cdot \mathbf b / |\mathbf b|$. multiply the unit vector of $\mathbf b$ by that length and you have the shadow as a vector, which is the first line. the sign comes along: a negative length means the shadow falls behind the tail of $\mathbf b$. what's left over, $\mathbf a - \operatorname{proj}_{\mathbf b}\mathbf a$, is perpendicular to $\mathbf b$, so every vector splits into a part along $\mathbf b$ and a part across it. for the page's pair, the shadow of $\mathbf a$ on $\mathbf b$ is $(6 / 10)(1, 3) = (0.6, 1.8)$, $6 / \sqrt{10} \approx 1.90$ long, and the rest is $(2.4, -0.8)$, which dots with $(1, 3)$ to 0.

### the angle

$$
\cos\theta = \frac{\mathbf a \cdot \mathbf b}{|\mathbf a|\,|\mathbf b|}
$$

solve the second form for the cosine, then take $\arccos$. for $\mathbf a = (3, 1)$ and $\mathbf b = (1, 3)$: $6 / (\sqrt{10}\sqrt{10}) = 0.6$, so $\theta = \arccos 0.6 \approx 53.13°$. two unit vectors skip the division: their dot product is the cosine itself. on a computer, rounding can push the ratio a hair past 1, where $\arccos$ has no answer; the [cg fundamentals page](/graphics/cg-fundamentals/#vectors--matrices) shows the case and the fix, an $\operatorname{atan2}$ form, which is what the explore figure uses. for the direction of one vector as an angle from the $x$ axis, it's $\operatorname{atan2}(y, x)$, on the [trig page](/math/trig/#going-back).

### signed area

$$
a_x b_y - a_y b_x = |\mathbf a|\,|\mathbf b|\sin\theta
$$

the parallelogram with sides $\mathbf a$ and $\mathbf b$ has base $|\mathbf a|$ and height $|\mathbf b|\sin\theta$. the cross-multiplied components give the same area with a sign: positive when $\mathbf b$ is counter-clockwise from $\mathbf a$, negative when it's clockwise, 0 when they're parallel. for the page's pair, $3 \cdot 3 - 1 \cdot 1 = 8$. the sign is how a game tells whether a point is left or right of a line. in 3d the same arithmetic, done three times, is the cross product, a vector perpendicular to both; the [cg fundamentals page](/graphics/cg-fundamentals/#vectors--matrices) covers it. on the [matrices page](/math/matrices/#the-determinant) this number is the determinant of the matrix with $\mathbf a$ and $\mathbf b$ as its columns.

## worked examples

**a step between points.** $p = (2, -1)$ and $q = (4, 3)$. the step from $p$ to $q$ is $q - p = (4 - 2,\ 3 - (-1)) = (2, 4)$, and its length is the distance between them: $\sqrt{4 + 16} = \sqrt{20} \approx 4.47$. $p + q = (6, 2)$ is a legal sum of numbers but not a meaningful place.

**a unit vector.** $\mathbf v = (-3, 4)$. $|\mathbf v| = \sqrt{9 + 16} = 5$, so $\mathbf v / |\mathbf v| = (-0.6, 0.8)$. check: $0.36 + 0.64 = 1$. a speed of 10 in that direction is the velocity $10 \cdot (-0.6, 0.8) = (-6, 8)$.

**the angle between two arrows.** $\mathbf u = (4, 2)$ and $\mathbf w = (1, 3)$. $\mathbf u \cdot \mathbf w = 4 + 6 = 10$. $|\mathbf u| = \sqrt{20} \approx 4.47$ and $|\mathbf w| = \sqrt{10} \approx 3.16$, and their product is $\sqrt{200} = 10\sqrt 2 \approx 14.14$. so $\cos\theta = 10 / (10\sqrt 2) = 1 / \sqrt 2$, and $\theta = 45°$ exactly.

**a projection.** a force $\mathbf f = (3, 4)$ pulls on a block on a ramp that runs along $\mathbf d = (2, 1)$. how much of the force pulls along the ramp? $\mathbf f \cdot \mathbf d / |\mathbf d| = (6 + 4) / \sqrt 5 = 10 / \sqrt 5 = 2\sqrt 5 \approx 4.47$. as a vector: $(\mathbf f \cdot \mathbf d / \mathbf d \cdot \mathbf d)\,\mathbf d = (10 / 5)(2, 1) = (4, 2)$. the rest, $\mathbf f - (4, 2) = (-1, 2)$, presses into the ramp: it's perpendicular to $\mathbf d$, since $(-1) \cdot 2 + 2 \cdot 1 = 0$.

**which side.** $\mathbf a = (4, 1)$ and $\mathbf b = (-2, 3)$. $\mathbf a \cdot \mathbf b = -8 + 3 = -5$: negative, so the angle is past 90° (it's about $109.65°$). $a_x b_y - a_y b_x = 12 + 2 = 14$: positive, so $\mathbf b$ is counter-clockwise from $\mathbf a$, and the parallelogram they span has area 14.

**reaching a point.** write $(5, 1)$ as $s(2, 1) + t(1, -1)$. part by part: $2s + t = 5$ and $s - t = 1$. add the two equations: $3s = 6$, so $s = 2$ and $t = 1$. check: $2(2, 1) + (1, -1) = (4, 2) + (1, -1) = (5, 1)$. two equations, two unknowns: the [linear systems page](/math/linear-systems/) does this in general.

## the key idea up close

### why the two dot products agree

the two forms of the dot product look unrelated: one is arithmetic on components, the other is two lengths and an angle. the law of cosines ties them together.

> **interactive figure:** a triangle: a = (3, 1) in cyan and b = (1, 3) in amber from the origin, the angle θ between them marked at the origin, and a − b = (2, −2) in white from the tip of b to the tip of a as the third side. the sides are labeled |a| = √10, |b| = √10 and |a − b| = √8: about 3.16, 3.16 and 2.83.

put $\mathbf a$ and $\mathbf b$ tail to tail. the third side of the triangle is $\mathbf a - \mathbf b$, and the angle between $\mathbf a$ and $\mathbf b$ is $\theta$. the law of cosines, pythagoras with a correction for the angle, says

$$
\begin{aligned}
|\mathbf a - \mathbf b|^2 &= |\mathbf a|^2 + |\mathbf b|^2 \\
&\quad - 2\,|\mathbf a|\,|\mathbf b|\cos\theta
\end{aligned}
$$

now take the left side apart with components. write $\mathbf a \cdot \mathbf b$ for $a_x b_x + a_y b_y$, the component form, and use two facts about it that are plain arithmetic: $\mathbf a \cdot \mathbf a = a_x^2 + a_y^2 = |\mathbf a|^2$, and it spreads over sums and differences the way multiplication does. then

$$
\begin{aligned}
|\mathbf a - \mathbf b|^2 &= (\mathbf a - \mathbf b) \cdot (\mathbf a - \mathbf b) \\
&= \mathbf a \cdot \mathbf a - 2\,\mathbf a \cdot \mathbf b + \mathbf b \cdot \mathbf b \\
&= |\mathbf a|^2 - 2\,\mathbf a \cdot \mathbf b + |\mathbf b|^2
\end{aligned}
$$

both say what the squared third side is. set them equal, cancel $|\mathbf a|^2 + |\mathbf b|^2$ from both sides and divide by $-2$:

$$
\mathbf a \cdot \mathbf b = |\mathbf a|\,|\mathbf b|\cos\theta
$$

with the page's pair: $|\mathbf a - \mathbf b|^2 = |(2, -2)|^2 = 8$, and $|\mathbf a|^2 + |\mathbf b|^2 - 2\,\mathbf a \cdot \mathbf b = 10 + 10 - 12 = 8$. the same argument runs in 3d with one more component, which is why a shader can take the cosine of the angle between a normal and a light without ever finding the angle.

## pitfalls

- **|a + b| isn't |a| + |b|.** the vectors add part by part, but their lengths don't, unless the arrows point the same way. for the page's pair, $|\mathbf a| + |\mathbf b| \approx 6.32$ while $|\mathbf a + \mathbf b| \approx 5.66$. the triangle inequality says which way it always goes: $|\mathbf a + \mathbf b| \le |\mathbf a| + |\mathbf b|$, with equality only for the same direction.
- **normalizing the zero vector.** $(0, 0)$ has length 0, so dividing by it is $0 / 0$: NaN in javascript, and NaN spreads to everything it touches. check the length first, as the comment in the cg page's `normalize` says.
- **acos of a rounded ratio.** $\mathbf a \cdot \mathbf b / (|\mathbf a|\,|\mathbf b|)$ can come out a hair past 1, and $\arccos$ of that is NaN. the [cg fundamentals page](/graphics/cg-fundamentals/#vectors--matrices) shows the case and the fix.
- **a point isn't a vector.** both are written $(x, y)$. a point is a place, a vector is a step. point minus point is a vector, point plus vector is a point, and point plus point means nothing. the [cg fundamentals page](/graphics/cg-fundamentals/#transforms) keeps them apart with a fourth coordinate.
- **a · b is only the cosine for unit vectors.** $(0.6, 0.8) \cdot (1, 0) = 0.6 = \cos 53.13°$. but $(3, 4) \cdot (1, 0) = 3$ and $(3, 4) \cdot (2, 0) = 6$: scale either arrow and the dot product scales with it. divide by the lengths first, or normalize both.
- **the dot product is a number, not a vector.** $\mathbf a \cdot \mathbf b$ has no direction, so $(\mathbf a \cdot \mathbf b)\,\mathbf c$ is a stretched $\mathbf c$ and $\mathbf a\,(\mathbf b \cdot \mathbf c)$ is a stretched $\mathbf a$: two different vectors. $\mathbf a \cdot \mathbf b \cdot \mathbf c$ doesn't mean anything.

## practice

1. $\mathbf a = (-2, 5)$ and $\mathbf b = (4, -1)$. find $\mathbf a + \mathbf b$, $\mathbf a - \mathbf b$, $3\mathbf a$ and $|\mathbf b|$.

   **answer:** part by part: $\mathbf a + \mathbf b = (2, 4)$, $\mathbf a - \mathbf b = (-6, 6)$, $3\mathbf a = (-6, 15)$. $|\mathbf b| = \sqrt{16 + 1} = \sqrt{17} \approx 4.12$.

2. find the unit vector in the direction of $(5, -12)$.

   **answer:** $|(5, -12)| = \sqrt{25 + 144} = \sqrt{169} = 13$, so the unit vector is $(5 / 13,\ -12 / 13) \approx (0.385, -0.923)$. check: $25 / 169 + 144 / 169 = 1$.

3. $\mathbf p = (3, 4)$. show that $\mathbf q = (4, -3)$ is perpendicular to it, and find the angle between $\mathbf p$ and $\mathbf r = (7, 1)$.

   **answer:** $\mathbf p \cdot \mathbf q = 12 - 12 = 0$, so they're perpendicular: $\mathbf q$ is $\mathbf p$ with the parts swapped and one sign flipped. $\mathbf p \cdot \mathbf r = 21 + 4 = 25$, $|\mathbf p| = 5$ and $|\mathbf r| = \sqrt{50} \approx 7.07$, so $\cos\theta = 25 / (5\sqrt{50}) = 5 / \sqrt{50} = 1 / \sqrt 2$ and $\theta = 45°$.

4. find the shadow of $(6, 2)$ on $(1, 1)$, and the part of $(6, 2)$ that's perpendicular to $(1, 1)$.

   **answer:** $(6, 2) \cdot (1, 1) = 8$ and $(1, 1) \cdot (1, 1) = 2$, so the shadow is $(8 / 2)(1, 1) = (4, 4)$, which is $8 / \sqrt 2 = 4\sqrt 2 \approx 5.66$ long. the rest is $(6, 2) - (4, 4) = (2, -2)$, and $(2, -2) \cdot (1, 1) = 0$, so it's perpendicular. the two parts add back to $(6, 2)$.

5. find $s$ and $t$ with $s(1, 2) + t(3, 1) = (7, 9)$. what's the signed area of the parallelogram $(1, 2)$ and $(3, 1)$ span, and what does it have to do with the answer?

   **answer:** part by part: $s + 3t = 7$ and $2s + t = 9$. the second gives $t = 9 - 2s$; in the first, $s + 27 - 6s = 7$, so $s = 4$ and $t = 1$. check: $(4, 8) + (3, 1) = (7, 9)$. the signed area is $1 \cdot 1 - 2 \cdot 3 = -5$: negative, so $(3, 1)$ is clockwise from $(1, 2)$. it's not 0, so the two aren't parallel, and that's why exactly one pair $s, t$ reaches $(7, 9)$, or any other point.

6. when does $|\mathbf a + \mathbf b|$ equal $|\mathbf a| + |\mathbf b|$? try $\mathbf a = (2, 1)$ with $\mathbf b = (4, 2)$, then with $\mathbf b = (-1, 2)$.

   **answer:** only when the arrows point the same way, so the head-to-tail route doesn't bend. $(4, 2) = 2\mathbf a$ does: $|\mathbf a| = \sqrt 5 \approx 2.24$, $|\mathbf b| = \sqrt{20} \approx 4.47$, and $\mathbf a + \mathbf b = (6, 3)$ has length $\sqrt{45} \approx 6.71$, the sum. $(-1, 2)$ doesn't: $|\mathbf b| = \sqrt 5 \approx 2.24$ too, so $|\mathbf a| + |\mathbf b| \approx 4.47$, but $\mathbf a + \mathbf b = (1, 3)$ is only $\sqrt{10} \approx 3.16$ long. in fact $\mathbf a \cdot \mathbf b = -2 + 2 = 0$: these two are perpendicular, and the sum is the hypotenuse.

## related

- https://learning.anthnydas.com/math/matrices.md
- https://learning.anthnydas.com/math/linear-systems.md
- https://learning.anthnydas.com/math/eigenvectors.md
- https://learning.anthnydas.com/math/trig.md
- https://learning.anthnydas.com/graphics/cg-fundamentals.md
- game dev (soon)
