Orthogonal and Orthonormal Vectors in Linear Algebra

Shlok Kumar - Feb 14 - - Dev Community

In linear algebra, understanding orthogonal and orthonormal vectors is crucial, especially for applications in machine learning. This blog post will simplify these concepts without delving too deeply into complex mathematics.

Orthogonal Vectors

Two vectors are considered orthogonal if their dot product equals zero. But what exactly is the dot product? The dot product (or scalar product) of two n-dimensional vectors, A and B, can be expressed as follows:

A · B = ∑ (from i=1 to n) a_i * b_i
Enter fullscreen mode Exit fullscreen mode

Thus, vectors A and B are orthogonal if:

A · B = 0
Enter fullscreen mode Exit fullscreen mode

Example

Consider two vectors in 3D space:

  • ( v_1 = [1, -2, 4] )
  • ( v_2 = [2, 5, 2] )

To check if they are orthogonal, we calculate their dot product:

v_1 · v_2 = [1, -2, 4] · [2, 5, 2] = 1*2 + (-2)*5 + 4*2 = 0
Enter fullscreen mode Exit fullscreen mode

Since the result is zero, the vectors are orthogonal.

Python Code Example

Here's a simple Python program that illustrates orthogonal vectors:

# A python program to illustrate orthogonal vector

# Import numpy module
import numpy

# Taking two vectors
v1 = [[1, -2, 4]]
v2 = [[2, 5, 2]]

# Transpose of v1
transposeOfV1 = numpy.transpose(v1)

# Matrix multiplication of both vectors
result = numpy.dot(v2, transposeOfV1)
print("Result =", result)

# Output
# Result = 0
Enter fullscreen mode Exit fullscreen mode

Unit Vectors

Next, let's discuss unit vectors. A unit vector is derived from a vector by dividing it by its magnitude. For a vector ( A ), the unit vector ( \hat{a} ) is defined as:

\hat{a} = A / |A|
Enter fullscreen mode Exit fullscreen mode

Example

Consider a vector ( A ) in 2D space:

  • ( A = [3, 4] )

The magnitude of ( A ) is calculated as follows:

|A| = √(3² + 4²) = 5
Enter fullscreen mode Exit fullscreen mode

Thus, the unit vector ( \hat{a} ) is:

\hat{a} = A / |A| = [3/5, 4/5]
Enter fullscreen mode Exit fullscreen mode

Properties of Unit Vectors

  • Unit vectors define directions in a coordinate system.
  • Any vector can be expressed as a product of a unit vector and a scalar magnitude.

Orthonormal Vectors

Orthonormal vectors are not only orthogonal but also have unit magnitude. To convert orthogonal vectors into orthonormal vectors, simply divide each vector by its magnitude.

For the vectors we considered earlier:

  • For ( v_1 = [1, -2, 4] ):
v_1' = v_1 / |v_1| = [1, -2, 4] / √(1² + (-2)² + 4²)
Enter fullscreen mode Exit fullscreen mode
  • For ( v_2 = [2, 5, 2] ):
v_2' = v_2 / |v_2| = [2, 5, 2] / √(2² + 5² + 2²)
Enter fullscreen mode Exit fullscreen mode

By converting these vectors into unit vectors, they remain orthogonal and achieve unit magnitude, hence forming orthonormal vectors.

Note

All orthonormal vectors are inherently orthogonal, as defined by their properties.

For more content, follow me at -  https://linktr.ee/shlokkumar2303

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .