Vector, Scalar, and Matrix Arithmetic

Published

Vector Math:

Vectors are sometimes denoted by bracketed numbers representing directions.

Example - 2D Vector:

\begin{bmatrix} x \\ y \end{bmatrix}

Example - 3D Vector:

\begin{bmatrix} x \\ y\\ z \end{bmatrix}

Addition:

To add two vectors, just add each element in one vector with its counterpart in the other vector.

Example:

\overrightarrow{VectorA} = \begin{bmatrix} 2 \\ 3\\ 4 \end{bmatrix} \\ \overrightarrow{VectorB} = \begin{bmatrix} 5 \\ 6\\ 7 \end{bmatrix} \\ \begin{bmatrix} 2 \\ 3\\ 4 \end{bmatrix} + \begin{bmatrix} 5 \\ 6\\ 7 \end{bmatrix} = \begin{bmatrix} 7 \\ 9\\ 11 \end{bmatrix}

Subtraction:

Vector subtraction works the same as vector addition, but you subtract the elements instead of adding them.

Example:

\overrightarrow{VectorA} = \begin{bmatrix} 2 \\ 3\\ 4 \end{bmatrix} \\ \overrightarrow{VectorB} = \begin{bmatrix} 5 \\ 6\\ 7 \end{bmatrix} \\ \begin{bmatrix} 2 \\ 3\\ 4 \end{bmatrix} - \begin{bmatrix} 5 \\ 6\\ 7 \end{bmatrix} = \begin{bmatrix} -3 \\ -3\\ -3 \end{bmatrix}

Multiplication:

There are two different kinds of multiplication when it comes to vectors. They are the dot product and the cross product. Both methods give a vector that is at a right angle to the two vectors being multiplied, but the dot product results in a scalar and the cross product results in a vector.

Both the dot and cross product require the length (magnitude) of the vectors and the angle between them.

The cross product can only be done if both vectors are three dimensional.

Example - Dot Product:

The result of the dot product of two vectors will be a scalar. If the scalar is zero, then the two vectors are at a right angle to each other.

Example:

\overrightarrow{A} = \begin{bmatrix} 1\\ 2\\ 3 \end{bmatrix} ~~ \overrightarrow{B} = \begin{bmatrix} 4\\ 5\\ 6 \end{bmatrix} \\ \\ \overrightarrow{A} \cdot \overrightarrow{B} = (1 \times 4) + (2 \times 5) + (3 \times 6) \\ ~~~~~~~~~= 4 + 10 + 18 \\ ~~~~~~~~~= 14 + 18 \\ ~~~~~~~~~= 32

Cross Product with Two Vectors:

The result of the cross product of two vectors will be a vector. If the vector is filled with only zeros, then the two vectors are parallel to each other.

Example:
\overrightarrow{A} = \begin{bmatrix} 3\\ 2\\ -2 \end{bmatrix} ~~ \overrightarrow{B} = \begin{bmatrix} 1\\ 0\\ -5 \end{bmatrix} \\\\ If~you~line~up~the~vectors~in~the~following~way,~it~will~be~a~lot~easier~to~see\\ how~the~following~matrices~and~calculations~are~done.\\\\ \overrightarrow{A} \times \overrightarrow{B} = \begin{bmatrix} \hat{i}  \hat{j}  \hat{k}\\ 3  2  -2\\ 1  0  -5 \end{bmatrix} \\\\ To~get~the~first~matrix,~hold~your~finger~over~the~entire~\hat{i}~column,~to\\ get~the~second,~hold~your~finger~over~the~\hat{j}~column,~and~to~get~the~third\\ matrix, hold~your~finger~over~the~\hat{k}~column. \\\\ \overrightarrow{A} \times \overrightarrow{B} = \begin{bmatrix} 2  -2\\ 0  -5 \end{bmatrix} \hat{i} - \begin{bmatrix} 3  -2\\ 1  -5 \end{bmatrix} \hat{j} + \begin{bmatrix} 3  2\\ 1  0 \end{bmatrix} \hat{k} \\\\ \hat{i} = (-5 \times 2) - (-2 \times 0) = -10\\ \hat{j} = (-5 \times 3) - (-2 \times 1) = -15 + 2 = -13\\ \hat{k} = (0 \times 3) - (2 \times 1) = -2 \\\\ \overrightarrow{A} \times \overrightarrow{B} = -10\hat{i} - (-13\hat{j}) + (-2)\hat{k} = -10\hat{i} + 13\hat{j} - 2\hat{k} \\\\ This~can~also~be~written~as~the~following.\\ \overrightarrow{A} \times \overrightarrow{B} = \begin{bmatrix} -10\\13\\2 \end{bmatrix}

Division:

It isn't possible to divide one vector by another.

Scalar Math:

A scalar can be any real number. Both vectors and matrices can be multiplied by scalars.

Addition Subtraction:

Generally, a scalar cannot be added or subtracted with a vector or a matrix.

Multiplication:

A scalar can be multiplied with both vectors and matrices. When it comes to vectors you multiply the scalar by with the magnitude and direction for matrices you simply multiply each element in the matrix by the scalar.

Example - Vector/Matrix:

\displaystyle \overrightarrow{Vector} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} \\ Scalar = 5 \\ 5 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 15 \\ 20 \end{bmatrix}

Example - Matrix:

\displaystyle 2 * \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} = \begin{bmatrix} 2  & 4 \\ 6 & 8 \end{bmatrix}

Division:

To divide a matrix or vector with a scalar, just divide every element of the matrix or vector by the scalar.

Example - Vector/Matrix:

\displaystyle \begin{bmatrix} 2\\ 3\\ 4 \end{bmatrix} \div 5 = \begin{bmatrix} \frac{2}{5}\\\\ \frac{3}{5}\\ \\ \frac{4}{5} \end{bmatrix}

Example - Matrix:

\displaystyle \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \div 2 = \begin{bmatrix} \frac{1}{2} & \frac{2}{2} \\\\ \frac{3}{2} & \frac{4}{2} \end{bmatrix} = \begin{bmatrix} \frac{1}{2} & 1 \\\\ \frac{3}{2} & 2 \end{bmatrix}

Matrix Math:

To do any of the following operations on two matrices, both matrices must be of the same size. As an example, only a 3x3 matrix can be added, subtracted, or multiplied by another 3x3 matrix.

Addition:

To do matrix addition you simply need to add the first element in the first matrix to the first element to the second matrix and so on.

Example:

\displaystyle \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} + \begin{bmatrix} 10 & 9 \\ 8 & 7 \end{bmatrix} = \begin{bmatrix} 1 + 10 & 2 + 9 \\ 3 + 8 & 4 + 7 \end{bmatrix} = \begin{bmatrix} 11 & 11 \\ 11 & 11 \end{bmatrix}

Subtraction:

Matrix subtraction works the same as addition, but you subtract the elements instead of adding them.

Example:

\displaystyle \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} - \begin{bmatrix} 10 & 9 \\ 8 & 7 \end{bmatrix} = \begin{bmatrix} 1 - 10 & 2 - 9 \\ 3 - 8 & 4 - 7 \end{bmatrix} = \begin{bmatrix} -9 & -7 \\ -5 & -3 \end{bmatrix} = - \begin{bmatrix} 9 & 7 \\ 5 & 3 \end{bmatrix}

Multiplication:

To do matrix multiplication, you need two matrices where the first one has the same number of rows as the second has columns. If these conditions aren't met, then you cannot multiply two matrices.

Example:

\displaystyle \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \times \begin{bmatrix} 7 & 8 \\ 9 & 10 \\ 11 & 12 \end{bmatrix} = \begin{bmatrix} (1 * 7) + (2 * 9) + (3 * 11) & (1 * 8) + (2 * 10) + (3 * 12) \\ (4 * 7) + (5 * 9) + (6 * 11) & (4 * 8) + (5 * 10) + (6 * 12) \end{bmatrix} \\ ~~~~~~~~~~~~~~~~~~~~~~ = \begin{bmatrix} 58 & 64 \\ 139 & 154 \end{bmatrix}

Division:

It isn't possible to divide one matrix by another.

References: