> For the complete documentation index, see [llms.txt](https://exobrain.stfwn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://exobrain.stfwn.com/linear-algebra/orthogonality.md).

# Orthogonality

## Orthogonal set and basis

An **orthogonal set** is a set in which all pairs of distinct vectors are orthogonal. Similarly, an **orthogonal basis** is a basis that is an orthogonal set.

If $${\vec{v\_1}, ..., \vec{v\_n}}$$ is an orthogonal basis for a subspace $$W$$ and $$\vec{w}$$ is a vector in $$W$$, the scalars $$c\_i, ..., c\_n$$ that express $$w$$ as a linear combination of $${\vec{v\_1}, ..., \vec{v\_n}}$$ are given by:

$$
c\_i = \frac{w \cdot v\_i}{v\_i \cdot v\_i} \text{for } i = 1, ..., n
$$

## Orthonormal set and basis

A set of vectors in $$R^n$$ is called an **orthonormal set** if it is an orthogonal set of *unit vectors*. Likewise, an **orthonormal basis** is an orthonormal set that is a basis for some subspace. You can easily obtain an orthonormal set from an orthogonal set by normalizing each vector in the set.

If $${\vec{q\_1}, \vec{q\_2}, ..., \vec{q\_n}}$$ is an orthonormal basis for subspace $$W$$ and $$\vec{w}$$ is in $$W$$, then $$\vec{w}$$ can be expressed as a combination of projections:

$$
w = (w \cdot q\_1)q\_1 + (w \cdot q\_2)q\_2 + ... + (w \cdot q\_n)q\_n
$$

## Orthogonal Matrix

Somewhat confusingly, a *square* matrix in which the columns form an orthonormal set is called an **orthogonal matrix**. There is no name for a non-square matrix with orthonormal columns.

An orthogonal matrix some nice properties. Some of these are a bit obvious but it's nice to have them in a list. For any orthogonal matrix $$Q$$ with dimension $$n \times n$$:

* $$Q^{-1} = Q^T$$.
* $$||Q\vec{x}|| = ||\vec{x}||$$ for any $$x$$ in $$R^n$$.
* Any eigenvalues $$\lambda$$ of $$Q$$ have $$|\lambda| = 1$$.
* $$Q \vec{x} \cdot Q \vec{y} = \vec{x} \cdot \vec{y}$$ for every $$x$$ and $$y$$ in $$R^n$$.
* $$Q^{-1}$$ is orthogonal.
* $$det(Q) = \pm 1$$.

## Orthogonal Projection

If $$W$$ is some subspace of $$R^n$$ and $${\vec{u\_1}, ..., \vec{u\_n}}$$ is an orthogonal basis for $$W$$, for any $$\vec{v}$$ in $$R^n$$, the **orthogonal projection of v onto W** is defined as:

$$
proj\_W (v) = (\frac{u\_1 \cdot v}{u\_1 \cdot u\_1})u\_1 + ... + (\frac{u\_n \cdot v}{u\_n \cdot u\_n})u\_n
$$

The **component of v orthogonal to W** is the vector:

$$
perp\_W (v) = v - proj\_W (v)
$$
