Vector Operations

Basic vector operations.

This is a vector in three dimensions:

v = {1,3,2}

This gives a vector u in the direction opposite to v with twice the magnitude:

u = -2 v

This reassigns the first component of u to be its negative:

u[[1]] = -u[[1]]; u

This gives the dot product of u and v:

u.v

This is the norm of v:

Norm[v]

This is the unit vector in the same direction as v:

Normalize[v]

This verifies that the norm is 1:

Norm[%]

Transform v to have zero mean and unit sample variance:

Standardize[v]

This shows the transformed values have mean 0 and variance 1:

{Mean[%],Variance[%]}

Two vectors are orthogonal if their dot product is zero. A set of vectors is orthonormal if they are all unit vectors and are pairwise orthogonal.

Orthogonal vector operations.

This gives the projection of u onto v:

p = Projection[u,v]

p is a scalar multiple of v:

p/v

u-p is orthogonal to v:

(u - p).v

Starting from the set of vectors {u,v}, this finds an orthonormal set of two vectors:

Orthogonalize[{u,v}]

When one of the vectors is linearly dependent on the vectors preceding it, the corresponding position in the result will be a zero vector:

Orthogonalize[{v, p, u}]