Updated 2017 November 17th

WordPress now supports LaTeX. To display LaTeX, just surround the code with "$latex" and "$", without the quotations. In this post, I show some formulae from this tutorial on SVD. I've shown the code for each formula; you can also mouseover the formula to see the code.

## Displaying a vector

`\vec{x} = \begin{pmatrix}8\\6\\7\\5\\3\end{pmatrix}`

## Displaying a matrix

`\begin{bmatrix} 17 & 18 & 5 & 5 & 45 & 1 \\ 42 & 28 & 30 & 15 & 115 & 3 \\ 10 & 10 & 10 & 21 & 51 & 2 \\ 28 & 5 & 65 & 39 & 132 & 5 \\ 24 & 26 & 45 & 21 & 116 & 4 \end{bmatrix}`

`A = \begin{bmatrix} a_{11} & \cdots & a_{1j} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots & \ddots & \vdots \\ a_{i1} & \cdots & a_{ij} & \cdots & a_{in} \\ \vdots & \ddots & \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mj} & \cdots & a_{mn} \end{bmatrix}`

Above is an matrix, where are elements of the matrix , = the row and = the column. The sequence of numbers:

`A_{(i)} = (a_{i1}, \dotsc, a_{in})`

is the $$i_{th}$$ row of A, and the sequence of numbers

`A^{(j)} = (a_{1j}, \dotsc, a_{mj})`

is the $$j_{th}$$ column of A.

## Calculating vector length

The length of a vector is found by squaring each component, summing them, and taking the square root of the sum. If is a vector, its length is .

`{\lvert}\vec{v}{\rvert} = \sqrt{ \sum_{i=1}^{n}{x_i^2} }`

## Vector addition

`A = [a_{1}, a_{2}, \dotsc, a_{n}]`

`B = [b_{1}, b_{2}, \dotsc, b_{n}]`

`A + B = [a_{1} + b_{1}, a_{2} + b_{2}, \dotsc, a_{n} + b_{n}]`

## Scalar multiplication

Multiplying a scalar (real number) to a vector means multiplying every component by that real number to yield a new vector.

`\vec{v} = [3, 6, 8, 4] \times 1.5 = [4.5, 9, 12, 6]`

## Inner product

The *inner product* of two vectors (also called the *dot product* or *scalar product*) defines multiplication of vectors. The inner product of two vectors is denoted or .

`(\vec{x}, \vec{y}) = \vec{x} \cdot \vec{y} = \sum_{i=1}^{n}{x_{i}y_{i}}`

For example, if and , then

`\vec{x} \cdot \vec{y} = 1(3) + 6(2) + 7(8) + 3(4) = 83`

## Orthogonality

Two vectors are orthogonal to each other if their inner product equals zero. For example, the vectors and are orthogonal because

`[2, 1, -2, 4] \cdot [3, -6, 4, 2] = 2(3) + 1(-6) - 2(4) + 4(2) = 0`

## Normal vector

A *normal vector* (or *unit vector*) is a vector of length 1. If you divide each component by its vector length, you get the normal/unit vector.

If , then

`{\lvert}\vec{v}{\rvert} = \sqrt{2^2 + 4^2 + 1^2 + 2^2} = \sqrt{25} = 5`

Then is a normal vector because

`{\lvert}\vec{u}{\rvert} = \sqrt{(2/5)^2 + (4/5)^2 + (1/5)^2 + (2/5)^2} = \sqrt{25/25} = 1`

## Orthonormal vectors

Vectors of unit length that are orthogonal to each other are said to be orthonormal. For example

`\vec{u} = [2/5, 1/5, -2/5, 4/5]`

and

`\vec{v} = [3 / \sqrt{65}, -6 / \sqrt{65}, 4 / \sqrt{65}, 2 / \sqrt{65}]`

are orthonormal because

`{\lvert}\vec{u}\rvert = \sqrt{(2/5)^2 + (1/5)^2 + (-2/5)^2 + (4/5)^2} = 1`

`{\lvert}\vec{v}\rvert = \sqrt{(3 / \sqrt{65})^2 + (-6 / \sqrt{65})^2 + (4 / \sqrt{65})^2 + (2 / \sqrt{65})^2} = 1`

`\vec{u} \cdot \vec{v} = \frac{6}{5\sqrt{65}} - \frac{6}{5\sqrt{65}} - \frac{8}{5\sqrt{65}} + \frac{8}{5\sqrt{65}} = 0`

## Square matrix

A matrix is *square* when . To designate the size of a square matrix with n rows and columns, it is called *n-square*. A 3-square matrix

`A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}`

## Transpose

The transpose of matrix is

`A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}`

`A^T = \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix}`

## Matrix multiplication

It is possible to multiply two matrices only when the number of rows of the first matrix matches the number of columns of the second matrix.

`AB = \begin{bmatrix} 2 & 1 & 4 \\ 1 & 5 & 2 \end{bmatrix} \begin{bmatrix} 3 & 2 \\ -1 & 4 \\ 1 & 2 \end{bmatrix} = \begin{bmatrix} 9 & 16 \\ 0 & 26 \end{bmatrix}`

Here's the working

## Identity matrix

The identity matrix () is a square matrix where all components are 0 expect for components on the diagonal, which are equal to 1. If you multiple a matrix with an identity matrix, you end up with the matrix.

`AI = \begin{bmatrix}2 & 4 & 6 \\ 1 & 3 & 5 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} = \begin{bmatrix}2 & 4 & 6 \\ 1 & 3 & 5 \end{bmatrix}`

## Orthogonal matrix

Matrix is orthogonal if . Matrix is a symmetric matrix since it is equal to its transpose.

`A = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 3/5 & -4/5 \\ 0 & 4/5 & 3/5 \end{bmatrix}`

is orthogonal because

`AA^T = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 3/5 & -4/5 \\ 0 & 4/5 & 3/5 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 \\ 0 & 3/5 & 4/5 \\ 0 & -4/5 & 3/5 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}`

## Diagonal matrix

A diagonal matrix is a square matrix where all the entries are 0 when .

`A = \begin{bmatrix} a_{11} & 0 & 0 & 0 \\ 0 & a_{22} & 0 & 0 \\ 0 & 0 & a_{33} & 0 \\ 0 & 0 & 0 & a_{mm} \end{bmatrix}`

The trace of an square matrix is defined to be the sum of the elements on the main diagonal.

`tr(A) = \sum^{n}_{i=1} a_{ii} = a_{11} + a_{22} + \dots + a_{nn}`

## Determinant

A determinant is a function of a square matrix that reduces it to a single number. The determinant of a matrix is denoted or . If consists of one element , then . If is a 2 x 2 matrix, then

`{\lvert}A\rvert = \left| \begin{array}{cc} a & b \\ c & d \end{array} \right| = ad - bc`

The determinant of

`A = \begin{bmatrix} 4 & 1 \\ 1 & 2 \end{bmatrix}`

is

`{\lvert}A\rvert = \left| \begin{array}{cc} 4 & 1 \\ 1 & 2 \end{array} \right| = 4(2) - 1(1) = 7`

When the determinant of a matrix is 0, the inverse of the matrix does not exist.

## Eigenvectors and eigenvalues

An eigenvector is a nonzero vector that satisfies the equation

`A\vec{v} = \lambda\vec{v}`

where is a square matrix, is a scalar, and is the eigenvector. is called an *eigenvalue*.

## Useful links

LaTeX – Multiline equations, systems and matrices

Online LaTeX editor

This work is licensed under a Creative Commons

Attribution 4.0 International License.