ZRH --:--:--

Orthonormal bases

8 min read4 sections
On this page

Used in matrix multiplication. For two vectors use 1D array in python

import numpy as np
v = np.array([[1],[2],[3]])
g = np.array([[3],[2],[1]])

print((v.T@g)[0,0])
#or
print(np.dot(v.T,g)[0,0])

Definition:

Show code (13 lines)x∙y=[x1⋮xn]∙[y1⋮yn]=x1y1+⋯+xnyn=∑i=1nxiyi\mathbf{x} \bullet \mathbf{y} = \begin{bmatrix} x_1 \\ \vdots \\ x_n \end{bmatrix} \bullet \begin{bmatrix} y_1 \\ \vdots \\ y_n \end{bmatrix} = x_1 y_1 + \cdots + x_n y_n = \sum_{i=1}^n x_i y_i

Exercise 6.1.

Norm

Euclidean Norm is has a geometrical interpretation. Using pythagorean theorem as often as R2−1\mathbb{R}^2-1 we get the norm or length of a vector

∥x∥=∥[x1x2⋮xn]∥=x12+⋯+xn2\|x\| = \left\| \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} \right\| = \sqrt{x_1^2 + \cdots + x_n^2}

Linearity of the Euclidean norm doesn’t hold:

∥x+y∥≠∥x∥+∥y∥\left\|x + y \right\| \not= \left\|x\right\|+ \left\|y\right\|

In fact:

∥x+y∥<∥x∥+∥y∥\left\|x + y \right\| < \left\|x\right\|+ \left\|y\right\|

Since geometrically x+y represents the fast way (Triangle inequality).

The dot product of a vector with itself is the squared Euclidean norm:

x∙x=∥x∥2x \bullet x = \left\| x\right\|^2

Manhattan norm

Defined by: ∥x∥1=∣x1∣+⋯+∣xn∣\left\| x \right\|_1 = |x_1|+\cdots+|x_n|

Norm

Metric

Orthogonal Projection

Orthogonal Projection onto a line spanned by vector v Orthogonal Projection onto a line spanned by vector v.

projection=u∙v∥v∥2∗vprojection = \frac{u \bullet v}{\left\|v\right\|^2}*v

Find orthogonal vector w:

w=u−pw = u-p

we can write w as u=p+wu = p + w and yields a decomposition of u as sum of two vectors which are orthogonal.

Orthonormal

A set is orthogonal if any two vectors in that set are orthogonal (i.e., linear independent: dot product=0dot \space product = 0 or u∙v=0u\bullet v = 0).

A set is orthonormal if any two vectors in that set are orthogonal and each vector is normalized (i.e., norm=1norm = 1 or u∙u=12u\bullet u = 1^2).

  • An orthonormal set is also called orthonormal system (ONS for short).
  • Normalize vectors by diving each components with the norm (∥vector∥\left\|vector\right\|) of vector.
  • Orthonormal basis span a vector space:
    • each vector vv in that space can be formulated as linear transformation of those basis b1,b2b_1,b_2.
    • Finding the coordinates a1,a2a_1,a_2 can be done by a1=v∙b1a_1 = v\bullet b_1 and a2=v∙b2a_2=v \bullet b_2.
v=(v∙b1)∗b1+(v∙b2)∗b2v = (v\bullet b_1)*b_1 + (v\bullet b_2)*b_2

Whats the use of orthonormal basis (ONB)?

U linear subspace of R2\mathbb{R}^2 and b1,...bkb_1,...b_k is orthonormal basis of U. Then, for each vector∈Uvector \in U we have:

vector=a1∗b1+a2∗b2+...ak∗bkvector = a_1*b_1 +a_2*b_2 +...a_k*b_k

so we can decompose each vector into a linear combination of the orthonormal basis (think in geometrical terms where we scale and add x and y basis to display a vector). a1,..a_1,.. are the coordinates with respect to the basis and we normally have to solve a linear system with gaussian elimination to find these coordinates (where coordinates are the unknown: s1,s2,..s_1,s_2,..).

But with ONB we can directly calculate these coordinates with dot product:

vector=(v∙b1)b1+...vector = (v\bullet b_1)b1 + ...

In R2\mathbb{R}^2 with ı^î and j^\hat j:

[5 6]=([5 6]t∙[1 0]t)∗[1 0]t+([5 6]t∙[0 1]t)∗[0 1]t[5 \space 6] = ([5 \space 6]^t \bullet [1 \space 0]^t) * [1 \space 0]^t+ ([5\space 6]^t \bullet [0 \space 1]^t) * [0 \space 1]^t

The coordinate vector of [5 6][5 \space 6] is [5 6][5 \space 6] with respect to basis ii and jj but these are normally not the same.

Gram-Schmidt Process

Tips for normalizing (extract annoying variables that get canceld out later here π\pi ):

∥(6π−7π−6π)∥=1π(6−7−6)1π∥(6−7−6)∥=162+(−7)2+(−6)2(6−7−6)\left\|\begin{pmatrix} \frac{6}{\pi} \\ \frac{-7}{\pi} \\ \frac{-6}{\pi}\end{pmatrix} \right\| = \frac{\frac{1}{\pi} \begin{pmatrix} 6 \\ -7 \\ -6\end{pmatrix}}{\frac{1}{\pi}\left\|\begin{pmatrix} 6 \\ -7 \\ -6\end{pmatrix}\right\|} = \frac{1}{\sqrt{6^2+(-7)^2+(-6)^2}}\begin{pmatrix} 6 \\ -7 \\ -6\end{pmatrix}

Python:

numpy.linalg.norm(v,1) #Manhattan-norm
numpy.linalg.norm(v,2) #Euclidean-norm Deafault
numpy.linalg.norm(v,np.inf) #Maxnorm

# Gram-Schmidt-Process

Q,R = numpy.linalg.qr(A) #retursn two matrices: Q is results, R additional Infos

Spectral Theorem

Facts about: symmetric matrices (A = A.T)

  • Must be square matrix (n∗n=Rnn * n = \mathbb{R}^n)
  • Diagonalizable (so there exist an eigenbasis of Rn\mathbb{R}^n: so we can transfrom A with matrix consisting of eigenbasis)
  • if eigenvectors are different -> eigenspaces of these vectors are orthogonal
    • decomposed original space into subspaces which are orthogonal
  • Applying Gram-Schmidt on all eigenspaces, one obtains an orthonormal basis consisting of eigenvectors of A$ ^n$

Facts about: Orthogonal Matrices:

  • if v1,..vn∈Rnv_1,..v_n \in \mathbb{R}^n and form ONB:
    • Then the matrix V consisting of v1,..vnv_1,..v_n satisfies: VTV=InV^TV=I_n since dot product of individual columns are zero except with itself (gives 1).
  • Matrix V is called orthogonal (better: orthonormal?)
  • Inverse of V is VTV^T -Finally: VTAV=diagonale(A)V^TAV=diagonale(A)
  • Principal Axis Transformation(Matrix decomposition) $ A = VDV^T$

How to calculate V?:

  • Find all eigenvectors(+values)
  • Apply Gram-Schmidt to all eigenspaces

Singular Value Decomposition (SVD)

“Generalization of eigenvalue decomposition”. SVD exists for all matrices not just squared ones.

Principale Axis Decomposition:

  • A symmetric: A=VDVtA = VDV^t
    • VV is orthogonal, DD diagonale
    • If A symmetric then SVD is the same.
  • A general (rectangle): A=UΣVTA= U\Sigma V^T
    • UU orthogonal, Σ\Sigma orthogonal(“diagonal”)

Σ\Sigma has same shape as A with σ1,..σn\sigma_1,..\sigma_n as diagonal entries everything else is zero. These entries are the singular values of A (generalization of eigenvalues). We are only interested in non-zero singular values which equals the rank of A.

Angles between vectors

Back to top

Esc

Type at least two letters. Search covers every project and knowledge-base note.

oz@zrh: ~
QUICK DOSSIER · 30 SEC READ

OLIVER ZINGG

Psychologist and data scientist in Zürich. I design the study, model the data and explain what it means.

STATUS
Open to full-time data science roles from January 2027
NOW
Working student, data science & project management at Zurich Insurance (since Nov 2025)
THESIS
M.Sc. thesis (HSLU): leveraging double machine learning for robust decision-making, due December 2026
EDUCATION
M.Sc. Psychology (UZH, 5.6) · M.Sc. Applied Information & Data Science (HSLU, Dec 2026)
TOOLS
R, Python, SQL, Matlab · Power BI, Tableau · mixed models, ML, BERTopic

TOP CASE FILES

  1. Learning and memory formation in children and adolescents with psychiatric disordersMaster's thesis, UZH · 2023
  2. Support vector machines vs. CNNs for Alzheimer's disease classificationBachelor's thesis, UZH · 2021
  3. Simpson's paradox and mixed-effects modelsStatistics · 2023