notes

Log | Files | Refs

commit 281d9e2b08051abddccd58740f9a6f7f28fd13b6
parent 07d4f0d33d851db6ef9768a5ea55fab8c145ddc3
Author: ling0x <ling0x@users.noreply.github.com>
Date:   Sun, 14 Jun 2026 12:15:25 +0100

chore: format

Diffstat:
Dlinear_algebra/geometry/links.md | 13-------------
Alinear_algebra/geometry/links.txt | 13+++++++++++++
Dlinear_algebra/vectors/cross_product.md | 305------------------------------------------------------------------------------
Alinear_algebra/vectors/cross_product.txt | 251+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dlinear_algebra/vectors/dot_product.md | 231-------------------------------------------------------------------------------
Alinear_algebra/vectors/dot_product.txt | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dlinear_algebra/vectors/vectors.md | 49-------------------------------------------------
Alinear_algebra/vectors/vectors.txt | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 435 insertions(+), 598 deletions(-)

diff --git a/linear_algebra/geometry/links.md b/linear_algebra/geometry/links.md @@ -1,13 +0,0 @@ -# Tesseract - -https://en.wikipedia.org/wiki/Tesseract - -# Geometric Continuity - -C1, G1 Surfaces, etc.: - -https://en.wikipedia.org/wiki/Smoothness#Geometric_continuity - -# Mobius Strip - -https://en.wikipedia.org/wiki/M%C3%B6bius_strip diff --git a/linear_algebra/geometry/links.txt b/linear_algebra/geometry/links.txt @@ -0,0 +1,13 @@ +=============================================================================== +GEOMETRY LINKS +=============================================================================== + +TESSERACT +https://en.wikipedia.org/wiki/Tesseract + +GEOMETRIC CONTINUITY +C1, G1 Surfaces, etc.: +https://en.wikipedia.org/wiki/Smoothness#Geometric_continuity + +MOBIUS STRIP +https://en.wikipedia.org/wiki/M%C3%B6bius_strip diff --git a/linear_algebra/vectors/cross_product.md b/linear_algebra/vectors/cross_product.md @@ -1,305 +0,0 @@ -# Cross Product - -The **cross product** is an operation that takes two vectors in -$$ \mathbb{R}^3 $$ - -and returns another vector in $$ \mathbb{R}^3 $$ - -, written $\mathbf{a} \times \mathbf{b}$. Unlike the dot product, the result is -a vector, not a scalar. The cross product is only defined in three dimensions -(and in a generalized sense in seven dimensions; here we restrict to -$\mathbb{R}^3$). - -## Geometric meaning - -- **Direction:** $\mathbf{a} \times \mathbf{b}$ is perpendicular to both - $\mathbf{a}$ and $\mathbf{b}$, following the right-hand rule: if you point - your fingers along $\mathbf{a}$ and curl them toward $\mathbf{b}$, your thumb - points in the direction of $\mathbf{a} \times \mathbf{b}$. -- **Magnitude:** $\|\mathbf{a} \times \mathbf{b}\| = - \|\mathbf{a}\|\,\|\mathbf{b}\|\sin\theta$, where $\theta$ is the angle between - $\mathbf{a}$ and $\mathbf{b}$. So the length equals the area of the - parallelogram spanned by $\mathbf{a}$ and $\mathbf{b}$. - -## Algebraic definition - -For vectors - -$$ -\mathbf{a} = -\begin{pmatrix} -a_1\\ -a_2\\ -a_3 -\end{pmatrix}, -\quad -\mathbf{b} = -\begin{pmatrix} -b_1\\ -b_2\\ -b_3 -\end{pmatrix}, -$$ - -the cross product is - -$$ -\mathbf{a} \times \mathbf{b} = -\begin{pmatrix} -a_2 b_3 - a_3 b_2\\ -a_3 b_1 - a_1 b_3\\ -a_1 b_2 - a_2 b_1 -\end{pmatrix}. -$$ - -This can be remembered using the determinant of a formal $3\times 3$ matrix: - -$$ - -\mathbf{a} \times \mathbf{b} = \begin{vmatrix} \mathbf{e}_1 & \mathbf{e}_2 & -\mathbf{e}_3\\ a_1 & a_2 & a_3\\ b_1 & b_2 & b_3 \end{vmatrix} - -$$ - -$$ - -\mathbf{e}_1(a_2 b_3 - a_3 b_2) - -- \mathbf{e}_2(a_1 b_3 - a_3 b_1) - -* \mathbf{e}_3(a_1 b_2 - a_2 b_1), - -$$ - -where $\mathbf{e}_1, \mathbf{e}_2, \mathbf{e}_3$ are the standard unit vectors -in $\mathbb{R}^3$. - -### The "Cross-Out" Method (Fastest) - -The shorthand calculation for this is: - -1. Stack them: Write the components of the first vector over the second vector - twice. -2. Cross out the first and last columns. -3. Multiply in an 'X' pattern (top-left bot-right minus top-right bot-left) for - each remaining pair: - -<img src="/assets/cross_product_shorthand.png" alt="Cross Product Calculation" width="500"> - -## Rules of calculation (with examples in LaTeX) - -Let $\mathbf{a}, \mathbf{b}, \mathbf{c} \in \mathbb{R}^3$ and $\lambda \in -\mathbb{R}$. - ---- - -**1. Anticommutativity** - -Swapping the order flips the sign: - -$$ -\mathbf{a} \times \mathbf{b} = -\bigl(\mathbf{b} \times \mathbf{a}\bigr). -$$ - -Example: - -$$ -\begin{pmatrix} 1\\ 0\\ 0 \end{pmatrix} \times \begin{pmatrix} 0\\ 1\\ 0 \end{pmatrix} -= \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix}, -\quad -\begin{pmatrix} 0\\ 1\\ 0 \end{pmatrix} \times \begin{pmatrix} 1\\ 0\\ 0 \end{pmatrix} -= \begin{pmatrix} 0\\ 0\\ -1 \end{pmatrix}. -$$ - ---- - -**2. Distributivity over addition** - -$$ -\mathbf{a} \times (\mathbf{b} + \mathbf{c}) -= \mathbf{a} \times \mathbf{b} + \mathbf{a} \times \mathbf{c}, -\qquad -(\mathbf{a} + \mathbf{b}) \times \mathbf{c} -= \mathbf{a} \times \mathbf{c} + \mathbf{b} \times \mathbf{c}. -$$ - -Example (second component of $\mathbf{a} \times (\mathbf{b}+\mathbf{c})$): - -$$ -\mathbf{a} = \begin{pmatrix} 1\\ 2\\ 0 \end{pmatrix},\; -\mathbf{b} = \begin{pmatrix} 0\\ 1\\ 1 \end{pmatrix},\; -\mathbf{c} = \begin{pmatrix} 1\\ 0\\ 1 \end{pmatrix} -\;\Rightarrow\; -\mathbf{b}+\mathbf{c} = \begin{pmatrix} 1\\ 1\\ 2 \end{pmatrix}. -$$ - -$$ -\mathbf{a} \times \mathbf{b} = \begin{pmatrix} 2\\ -1\\ 1 \end{pmatrix},\quad -\mathbf{a} \times \mathbf{c} = \begin{pmatrix} 2\\ -1\\ -2 \end{pmatrix} -\;\Rightarrow\; -\mathbf{a} \times \mathbf{b} + \mathbf{a} \times \mathbf{c} = \begin{pmatrix} 4\\ -2\\ -1 \end{pmatrix}. -$$ - -$$ -\mathbf{a} \times (\mathbf{b}+\mathbf{c}) = \begin{pmatrix} 2\cdot 2 - 0\cdot 1\\ 0\cdot 1 - 1\cdot 2\\ 1\cdot 1 - 2\cdot 1 \end{pmatrix} = \begin{pmatrix} 4\\ -2\\ -1 \end{pmatrix}. -$$ - ---- - -**3. Scalar multiplication (homogeneity)** - -A scalar can be factored out of either slot: - -$$ -(\lambda \mathbf{a}) \times \mathbf{b} -= \mathbf{a} \times (\lambda \mathbf{b}) -= \lambda (\mathbf{a} \times \mathbf{b}). -$$ - -Example: with $\mathbf{a} = \begin{pmatrix} 1\\ 0\\ 0 \end{pmatrix}$, -$\mathbf{b} = \begin{pmatrix} 0\\ 1\\ 0 \end{pmatrix}$, $\lambda = 3$, - -$$ -(3\mathbf{a}) \times \mathbf{b} -= \begin{pmatrix} 3\\ 0\\ 0 \end{pmatrix} \times \begin{pmatrix} 0\\ 1\\ 0 \end{pmatrix} -= \begin{pmatrix} 0\\ 0\\ 3 \end{pmatrix} -= 3 \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix} -= 3(\mathbf{a} \times \mathbf{b}). -$$ - ---- - -**4. Cross product with the zero vector** - -$$ -\mathbf{a} \times \mathbf{0} = \mathbf{0} \times \mathbf{a} = \mathbf{0}. -$$ - ---- - -**5. Parallel vectors** - -$\mathbf{a}$ and $\mathbf{b}$ are parallel (or one is zero) if and only if - -$$ -\mathbf{a} \times \mathbf{b} = \mathbf{0}. -$$ - -Example: $\mathbf{a} = \begin{pmatrix} 2\\ 4\\ 6 \end{pmatrix}$, $\mathbf{b} -= \begin{pmatrix} 1\\ 2\\ 3 \end{pmatrix} = \tfrac{1}{2}\mathbf{a}$, so - -$$ -\mathbf{a} \times \mathbf{b} -= \begin{pmatrix} 4\cdot 3 - 6\cdot 2\\ 6\cdot 1 - 2\cdot 3\\ 2\cdot 2 - 4\cdot 1 \end{pmatrix} -= \begin{pmatrix} 0\\ 0\\ 0 \end{pmatrix}. -$$ - ---- - -**6. Self-cross product** - -$$ -\mathbf{a} \times \mathbf{a} = \mathbf{0}. -$$ - -(Special case of the parallel-vectors rule.) - ---- - -**7. Jacobi identity** - -$$ - -\mathbf{a} \times (\mathbf{b} \times \mathbf{c}) - -- \mathbf{b} \times (\mathbf{c} \times \mathbf{a}) -- \mathbf{c} \times (\mathbf{a} \times \mathbf{b}) = \mathbf{0}. - -$$ - ---- - -**8. Relation to dot product (vector triple product expansion)** - -$$ -\mathbf{a} \times (\mathbf{b} \times \mathbf{c}) -= (\mathbf{a} \cdot \mathbf{c})\mathbf{b} - (\mathbf{a} \cdot \mathbf{b})\mathbf{c}. -$$ - -Example: $\mathbf{a} = \mathbf{e}_1$, $\mathbf{b} = \mathbf{e}_2$, -$\mathbf{c} = \mathbf{e}_3$: - -$$ -\mathbf{a} \cdot \mathbf{c} = 0,\quad \mathbf{a} \cdot \mathbf{b} = 0 -\;\Rightarrow\; -\mathbf{a} \times (\mathbf{b} \times \mathbf{c}) = 0\cdot \mathbf{b} - 0\cdot \mathbf{c} = \mathbf{0}. -$$ - -$$ -\mathbf{b} \times \mathbf{c} = \mathbf{e}_1 -\;\Rightarrow\; -\mathbf{e}_1 \times \mathbf{e}_1 = \mathbf{0}. -$$ - ---- - -**9. Magnitude and angle** - -$$ -\|\mathbf{a} \times \mathbf{b}\|^2 -= \|\mathbf{a}\|^2 \|\mathbf{b}\|^2 - (\mathbf{a} \cdot \mathbf{b})^2. -$$ - -Equivalently, $\|\mathbf{a} \times \mathbf{b}\| = -\|\mathbf{a}\|\,\|\mathbf{b}\|\sin\theta$. - ---- - -**10. Relation to the dot product (scalar triple product)** - -$$ -\mathbf{a} \cdot (\mathbf{b} \times \mathbf{c}) -= \mathbf{b} \cdot (\mathbf{c} \times \mathbf{a}) -= \mathbf{c} \cdot (\mathbf{a} \times \mathbf{b}). -$$ - -This value is the (signed) volume of the parallelepiped spanned by $\mathbf{a}, -\mathbf{b}, \mathbf{c}$. Example: - -$$ -\mathbf{a} = \begin{pmatrix} 1\\ 0\\ 0 \end{pmatrix},\; -\mathbf{b} = \begin{pmatrix} 0\\ 1\\ 0 \end{pmatrix},\; -\mathbf{c} = \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix} -\;\Rightarrow\; -\mathbf{b} \times \mathbf{c} = \begin{pmatrix} 1\\ 0\\ 0 \end{pmatrix},\quad -\mathbf{a} \cdot (\mathbf{b} \times \mathbf{c}) = 1. -$$ - -## Worked example - -Compute $\mathbf{u} \times \mathbf{v}$ for - -$$ -\mathbf{u} = \begin{pmatrix} 2\\ -1\\ 3 \end{pmatrix},\qquad -\mathbf{v} = \begin{pmatrix} 1\\ 4\\ -2 \end{pmatrix}. -$$ - -$$ -\mathbf{u} \times \mathbf{v} -= \begin{pmatrix} -(-1)(-2) - (3)(4)\\ -(3)(1) - (2)(-2)\\ -(2)(4) - (-1)(1) -\end{pmatrix} -= \begin{pmatrix} -2 - 12\\ -3 + 4\\ -8 + 1 -\end{pmatrix} -= \begin{pmatrix} -10\\ 7\\ 9 \end{pmatrix}. -$$ - -Check: $\mathbf{u} \cdot (\mathbf{u} \times \mathbf{v}) = 2(-10) + (-1)(7) + -3(9) = -20 - 7 + 27 = 0$, and $\mathbf{v} \cdot (\mathbf{u} \times \mathbf{v}) -= 1(-10) + 4(7) + (-2)(9) = -10 + 28 - 18 = 0$, so the result is perpendicular -to both $\mathbf{u}$ and $\mathbf{v}$. diff --git a/linear_algebra/vectors/cross_product.txt b/linear_algebra/vectors/cross_product.txt @@ -0,0 +1,251 @@ +=============================================================================== +CROSS PRODUCT +=============================================================================== + +The cross product is an operation that takes two vectors in R^3 and returns +another vector in R^3, written a x b. Unlike the dot product, the result is a +vector, not a scalar. The cross product is only defined in three dimensions +(and in a generalized sense in seven dimensions; here we restrict to R^3). + + +------------------------------------------------------------------------------- +1. GEOMETRIC MEANING +------------------------------------------------------------------------------- + +Direction: + a x b is perpendicular to both a and b, following the right-hand rule: if you + point your fingers along a and curl them toward b, your thumb points in the + direction of a x b. + +Magnitude: + ||a x b|| = ||a|| * ||b|| * sin(theta) + + where theta is the angle between a and b. The length equals the area of the + parallelogram spanned by a and b. + + +------------------------------------------------------------------------------- +2. ALGEBRAIC DEFINITION +------------------------------------------------------------------------------- + +For vectors: + + | a1 | | b1 | + a = | a2 | b = | b2 | + | a3 | | b3 | + +the cross product is: + + | a2*b3 - a3*b2 | + a x b = | a3*b1 - a1*b3 | + | a1*b2 - a2*b1 | + +This can be remembered using the determinant of a formal 3x3 matrix: + + | e1 e2 e3 | + | a1 a2 a3 | = e1*(a2*b3 - a3*b2) + | b1 b2 b3 | - e2*(a1*b3 - a3*b1) + + e3*(a1*b2 - a2*b1) + +where e1, e2, e3 are the standard unit vectors in R^3. + + +------------------------------------------------------------------------------- +3. THE "CROSS-OUT" METHOD (FASTEST) +------------------------------------------------------------------------------- + +1. Stack them: write the components of the first vector over the second twice. + +2. Cross out the first and last columns. + +3. Multiply in an X pattern (top-left * bottom-right minus top-right * + bottom-left) for each remaining pair: + + a1 a2 a3 a1 a2 a3 + \/ \/ \/ + /\ /\ /\ + b1 b2 b3 b1 b2 b3 + + or: + + a1 b1 + a2 b2 + \/ + /\ + a3 b3 + \/ + /\ + a1 b1 + \/ + /\ + a2 b2 + a3 b3 + +Result: + + | a2*b3 - a3*b2 | + a x b = | a3*b1 - a1*b3 | + | a1*b2 - a2*b1 | + + +------------------------------------------------------------------------------- +4. RULES OF CALCULATION (WITH EXAMPLES) +------------------------------------------------------------------------------- + +Let a, b, c in R^3 and lambda in R. + + +4.1 Anticommutativity + +Swapping the order flips the sign: + + a x b = -(b x a) + +Example: + + | 1 | | 0 | | 0 | + | 0 | x | 1 | = | 0 | + | 0 | | 0 | | 1 | + + | 0 | | 1 | | 0 | + | 1 | x | 0 | = | 0 | + | 0 | | 0 | | -1 | + + +4.2 Distributivity over addition + + a x (b + c) = a x b + a x c + (a + b) x c = a x c + b x c + +Example (second component of a x (b + c)): + + | 1 | | 0 | | 1 | + a = | 2 | b = | 1 | c = | 0 | + | 0 | | 1 | | 1 | + + b + c = | 1 | + | 1 | + | 2 | + + a x b = | 2 | a x c = | 2 | + | -1 | | -1 | + | 1 | | -2 | + + a x b + a x c = | 4 | + | -2 | + | -1 | + + a x (b + c) = | 2*2 - 0*1 | | 4 | + | 0*1 - 1*2 | = | -2 | + | 1*1 - 2*1 | | -1 | + + +4.3 Scalar multiplication (homogeneity) + +A scalar can be factored out of either slot: + + (lambda*a) x b = a x (lambda*b) = lambda * (a x b) + +Example: a = | 1 |, b = | 0 |, lambda = 3 + + (3*a) x b = | 3 | | 0 | | 0 | + | 0 | x | 1 | = | 0 | + | 0 | | 0 | | 3 | + + = 3 * | 0 | = 3 * (a x b) + | 0 | + | 1 | + + +4.4 Cross product with the zero vector + + a x 0 = 0 x a = 0 + + +4.5 Parallel vectors + +a and b are parallel (or one is zero) if and only if: + + a x b = 0 + +Example: a = | 2 |, b = | 1 | = (1/2)*a + + | 4 | | 2 | + | 6 | | 3 | + + a x b = | 4*3 - 6*2 | | 0 | + | 6*1 - 2*3 | = | 0 | + | 2*2 - 4*1 | | 0 | + + +4.6 Self-cross product + + a x a = 0 + +(Special case of the parallel-vectors rule.) + + +4.7 Jacobi identity + + a x (b x c) - b x (c x a) - c x (a x b) = 0 + + +4.8 Relation to dot product (vector triple product expansion) + + a x (b x c) = (a . c)*b - (a . b)*c + +Example: a = e1, b = e2, c = e3: + + a . c = 0, a . b = 0 + => a x (b x c) = 0*b - 0*c = 0 + + b x c = e1 + => e1 x e1 = 0 + + +4.9 Magnitude and angle + + ||a x b||^2 = ||a||^2 * ||b||^2 - (a . b)^2 + +Equivalently: + + ||a x b|| = ||a|| * ||b|| * sin(theta) + + +4.10 Relation to the dot product (scalar triple product) + + a . (b x c) = b . (c x a) = c . (a x b) + +This value is the (signed) volume of the parallelepiped spanned by a, b, c. + +Example: + + a = | 1 | b = | 0 | c = | 0 | + | 0 | | 1 | | 0 | + | 0 | | 0 | | 1 | + + b x c = | 1 |, a . (b x c) = 1 + | 0 | + | 0 | + + +------------------------------------------------------------------------------- +5. WORKED EXAMPLE +------------------------------------------------------------------------------- + +Compute u x v for: + + | 2 | | 1 | + u = | -1 | v = | 4 | + | 3 | | -2 | + + u x v = | (-1)*(-2) - 3*4 | | 2 - 12 | | -10 | + | 3*1 - 2*(-2) | = | 3 + 4 | = | 7 | + | 2*4 - (-1)*1 | | 8 + 1 | | 9 | + +Check: + + u . (u x v) = 2*(-10) + (-1)*7 + 3*9 = -20 - 7 + 27 = 0 + v . (u x v) = 1*(-10) + 4*7 + (-2)*9 = -10 + 28 - 18 = 0 + +So the result is perpendicular to both u and v. diff --git a/linear_algebra/vectors/dot_product.md b/linear_algebra/vectors/dot_product.md @@ -1,231 +0,0 @@ -# Dot Product - -The dot product is an operation that takes two vectors of the same dimension and -returns a single real number (a scalar), often written with a centered dot like -\(\mathbf{a} \cdot \mathbf{b}\). - -## Algebraic definition - -For vectors in $$ \mathbb{R}^n $$ - -$$ -\mathbf{a} = -\begin{pmatrix} -a_1\\ -a_2\\ -\vdots\\ -a_n -\end{pmatrix}, -\quad -\mathbf{b} = -\begin{pmatrix} -b_1\\ -b_2\\ -\vdots\\ -b_n -\end{pmatrix}, -$$ - -their dot product is - -$$ - -\mathbf{a} \cdot \mathbf{b} = - -a_1 b_1 + a_2 b_2 + \dots + a_n b_n. - -$$ - -Example in $$ \mathbb{R}^3 $$ - -$$ - -\begin{pmatrix} 1\\ 3\\ -5 \end{pmatrix} \cdot \begin{pmatrix} 4\\ -2\\ -1 -\end{pmatrix} = - -1\cdot 4 + 3\cdot(-2) + (-5)\cdot(-1) = - -4 - 6 + 5 = 3. - -$$ - -## Geometric definition - -If $$ \mathbf{a}, \mathbf{b} \in \mathbb{R}^n $$ - -and $$ \theta $$ - -is the angle between them, then - -$$ \mathbf{a} \cdot \mathbf{b} $$ - -$$ \|\mathbf{a}\|\;\|\mathbf{b}\|\cos\theta, $$ - -where $$ \|\mathbf{a}\| $$ - -is the Euclidean length (norm) of $$ \mathbf{a} $$ - -From this, you also get - -$$ -\mathbf{a} \cdot \mathbf{a} = \|\mathbf{a}\|^2, -\quad -\|\mathbf{a}\| = \sqrt{\mathbf{a} \cdot \mathbf{a}}. -$$ - -## Basic calculation rules - -Let $$ \mathbf{a}, \mathbf{b}, \mathbf{c} \in \mathbb{R}^n $$ - -and $$ \lambda \in -\mathbb{R} $$ - -Then: - -- Commutativity: - - $$ - \mathbf{a} \cdot \mathbf{b} = \mathbf{b} \cdot \mathbf{a}. - $$ - -- Distributivity over addition: - - $$ - \mathbf{a} \cdot (\mathbf{b} + \mathbf{c}) = - \mathbf{a} \cdot \mathbf{b} + \mathbf{a} \cdot \mathbf{c}. - $$ - -- Homogeneity (scalar multiplication in one slot): - - $$ - (\lambda \mathbf{a}) \cdot \mathbf{b} = - \lambda (\mathbf{a} \cdot \mathbf{b}), \quad \mathbf{a} \cdot (\lambda \mathbf{b}) = - \lambda (\mathbf{a} \cdot \mathbf{b}). - $$ - -- Positivity: - - $$ - \mathbf{a} \cdot \mathbf{a} \ge 0 - \quad \text{and} \quad - \mathbf{a} \cdot \mathbf{a} = 0 \iff \mathbf{a} = \mathbf{0}. - $$ - -## Worked examples - -1. Simple 2D example - -Let - -$$ -\mathbf{u} = -\begin{pmatrix} -2\\ --1 -\end{pmatrix}, -\quad -\mathbf{v} = -\begin{pmatrix} -3\\ -4 -\end{pmatrix}. -$$ - -Then - -$$ \mathbf{u} \cdot \mathbf{v} -2\cdot 3 + (-1)\cdot 4 = -6 - 4 = -2. -$$ - -2. 4D example - -Let - -$$ -\mathbf{x} = -\begin{pmatrix} -2\\ -0\\ --3\\ -1 -\end{pmatrix}, -\quad -\mathbf{y} = -\begin{pmatrix} --1\\ -3\\ -1\\ -2 -\end{pmatrix}. -$$ - -Then - -$$ -\mathbf{x} \cdot \mathbf{y} = -2(-1) + 0(3) + (-3)(1) + 1(2) = --2 + 0 - 3 + 2 = --3. -$$ - -3. Using the geometric form to find an angle - -Let - -$$ -\mathbf{a} = -\begin{pmatrix} -1\\ -2 -\end{pmatrix}, -\quad -\mathbf{b} = -\begin{pmatrix} -2\\ -1 -\end{pmatrix}. -$$ - -Compute - -$$ - -\mathbf{a} \cdot \mathbf{b} = 1\cdot 2 + 2\cdot 1 4, - -$$ - -$$ - -\|\mathbf{a}\| = - -\sqrt{1^2 + 2^2} = - -\sqrt{5}, \quad \|\mathbf{b}\| = - -\sqrt{2^2 + 1^2} = - -\sqrt{5}. - -$$ - -So - -$$ - -\cos\theta = - -\frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\|\,\|\mathbf{b}\|} = - -\frac{4}{\sqrt{5}\sqrt{5}} = - -\frac{4}{5}, - -$$ - -and hence - -$$ -\theta = \arccos\!\left(\frac{4}{5}\right). -$$ diff --git a/linear_algebra/vectors/dot_product.txt b/linear_algebra/vectors/dot_product.txt @@ -0,0 +1,109 @@ +=============================================================================== +DOT PRODUCT +=============================================================================== + +The dot product is an operation that takes two vectors of the same dimension and +returns a single real number (a scalar), often written as a . b. + + +------------------------------------------------------------------------------- +1. ALGEBRAIC DEFINITION +------------------------------------------------------------------------------- + +For vectors in R^n: + + | a1 | | b1 | + | a2 | | b2 | + a = | .. | b = | .. | + | an | | bn | + +their dot product is: + + a . b = a1*b1 + a2*b2 + ... + an*bn + +Example in R^3: + + | 1 | | 4 | + | 3 | . | -2 | = 1*4 + 3*(-2) + (-5)*(-1) = 4 - 6 + 5 = 3 + | -5 | | -1 | + + +------------------------------------------------------------------------------- +2. GEOMETRIC DEFINITION +------------------------------------------------------------------------------- + +If a, b in R^n and theta is the angle between them, then: + + a . b = ||a|| * ||b|| * cos(theta) + +where ||a|| is the Euclidean length (norm) of a. + +From this, you also get: + + a . a = ||a||^2 + ||a|| = sqrt(a . a) + + +------------------------------------------------------------------------------- +3. BASIC CALCULATION RULES +------------------------------------------------------------------------------- + +Let a, b, c in R^n and lambda in R. Then: + +Commutativity: + + a . b = b . a + +Distributivity over addition: + + a . (b + c) = a . b + a . c + +Homogeneity (scalar multiplication in one slot): + + (lambda*a) . b = lambda * (a . b) + a . (lambda*b) = lambda * (a . b) + +Positivity: + + a . a >= 0 + a . a = 0 if and only if a = 0 + + +------------------------------------------------------------------------------- +4. WORKED EXAMPLES +------------------------------------------------------------------------------- + +4.1 Simple 2D example + + | 2 | + u = | -1 | v = | 3 | + | 4 | + + u . v = 2*3 + (-1)*4 = 6 - 4 = 2 + + +4.2 4D example + + | 2 | | -1 | + | 0 | | 3 | + x = | -3 | y = | 1 | + | 1 | | 2 | + + x . y = 2*(-1) + 0*3 + (-3)*1 + 1*2 = -2 + 0 - 3 + 2 = -3 + + +4.3 Using the geometric form to find an angle + + | 1 | | 2 | + a = | 2 | b = | 1 | + + a . b = 1*2 + 2*1 = 4 + + ||a|| = sqrt(1^2 + 2^2) = sqrt(5) + ||b|| = sqrt(2^2 + 1^2) = sqrt(5) + + cos(theta) = (a . b) / (||a|| * ||b||) + = 4 / (sqrt(5) * sqrt(5)) + = 4/5 + + theta = arccos(4/5) diff --git a/linear_algebra/vectors/vectors.md b/linear_algebra/vectors/vectors.md @@ -1,49 +0,0 @@ -# Vectors - -A vector is an object that has both **magnitude** (length) and **direction** and -is often represented as an ordered list of numbers, like components along -coordinate axes. In $\mathbb{R}^n$, a vector is typically written as a column or -row of $n$ real numbers and can be added to other vectors or scaled by real -numbers. - -1. Basic vector notation (inline): - -A vector in 2D can be written as $\vec{v} = (v_1, v_2)$. - -2. Column vector (display): - -A column vector in 3D: - -$$ -\vec{v} = \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} -$$ - -3. Vector in $\mathbb{R}^n$: - -In general, a vector in $\mathbb{R}^n$ is - -$$ -\vec{v} = \begin{bmatrix} v_1 \\ v_2 \\ \dots \\ v_n \end{bmatrix}. -$$ - -4. Vector addition and scalar multiplication: - -If $\vec{u} = (u_1, u_2)$ and $\vec{v} = (v_1, v_2)$, then - -$$ -\vec{u} + \vec{v} = (u_1 + v_1,\; u_2 + v_2) -$$ - -and for a scalar $a$, - -$$ -a\vec{v} = (av_1,\; av_2). -$$ - -5. Magnitude (length) of a vector: - -The length of $\vec{v} = (v_1, v_2, v_3)$ is - -$$ -\|\vec{v}\| = \sqrt{v_1^2 + v_2^2 + v_3^2}. -$$ diff --git a/linear_algebra/vectors/vectors.txt b/linear_algebra/vectors/vectors.txt @@ -0,0 +1,62 @@ +=============================================================================== +VECTORS +=============================================================================== + +A vector is an object that has both magnitude (length) and direction and is +often represented as an ordered list of numbers, like components along +coordinate axes. In R^n, a vector is typically written as a column or row of n +real numbers and can be added to other vectors or scaled by real numbers. + + +------------------------------------------------------------------------------- +1. BASIC VECTOR NOTATION (INLINE) +------------------------------------------------------------------------------- + +A vector in 2D can be written as: + + v = (v1, v2) + + +------------------------------------------------------------------------------- +2. COLUMN VECTOR (DISPLAY) +------------------------------------------------------------------------------- + +A column vector in 3D: + + | v1 | + v = | v2 | + | v3 | + + +------------------------------------------------------------------------------- +3. VECTOR IN R^n +------------------------------------------------------------------------------- + +In general, a vector in R^n is: + + | v1 | + | v2 | + v = | .. | + | vn | + + +------------------------------------------------------------------------------- +4. VECTOR ADDITION AND SCALAR MULTIPLICATION +------------------------------------------------------------------------------- + +If u = (u1, u2) and v = (v1, v2), then: + + u + v = (u1 + v1, u2 + v2) + +and for a scalar a: + + a*v = (a*v1, a*v2) + + +------------------------------------------------------------------------------- +5. MAGNITUDE (LENGTH) OF A VECTOR +------------------------------------------------------------------------------- + +The length of v = (v1, v2, v3) is: + + ||v|| = sqrt(v1^2 + v2^2 + v3^2)