orth

Orthonormal basis for range of symbolic matrix

Syntax

B = orth(A)
B = orth(A,'real')
B = orth(A,'skipNormalization')
B = orth(A,'real','skipNormalization')

Description

B = orth(A) computes an orthonormal basis for the range of A.

B = orth(A,'real') computes an orthonormal basis using a real scalar product in the orthogonalization process.

B = orth(A,'skipNormalization') computes a non-normalized orthogonal basis. In this case, the vectors forming the columns of B do not necessarily have length 1.

B = orth(A,'real','skipNormalization') computes a non-normalized orthogonal basis using a real scalar product in the orthogonalization process.

Input Arguments

A

Symbolic matrix.

'real'

Flag that prompts orth to avoid using a complex scalar product in the orthogonalization process.

'skipNormalization'

Flag that prompts orth to skip normalization and compute an orthogonal basis instead of an orthonormal basis. If you use this flag, lengths of the resulting vectors (the columns of matrix B) are not required to be 1.

Output Arguments

B

Symbolic matrix.

Examples

Compute an orthonormal basis of the range of this matrix. Because these numbers are not symbolic objects, you get floating-point results.

A = [2 -3 -1; 1 1 -1; 0 1 -1];
B = orth(A)
B =
   -0.9859   -0.1195    0.1168
    0.0290   -0.8108   -0.5846
    0.1646   -0.5729    0.8029

Now, convert this matrix to a symbolic object, and compute an orthonormal basis:

A = sym([2 -3 -1; 1 1 -1; 0 1 -1]);
B = orth(A)
B =
[ (2*5^(1/2))/5, -6^(1/2)/6, -(2^(1/2)*15^(1/2))/30]
[     5^(1/2)/5,  6^(1/2)/3,  (2^(1/2)*15^(1/2))/15]
[             0,  6^(1/2)/6,  -(2^(1/2)*15^(1/2))/6]

You can use double to convert this result to the double-precision numeric form. The resulting matrix differs from the matrix returned by the MATLAB® orth function because these functions use different versions of the Gram-Schmidt orthogonalization algorithm:

double(B)
ans =
    0.8944   -0.4082   -0.1826
    0.4472    0.8165    0.3651
         0    0.4082   -0.9129

Verify that B'*B = I, where I is the identity matrix:

B'*B
ans =
[ 1, 0, 0]
[ 0, 1, 0]
[ 0, 0, 1]

Now, verify that the 2-norm of each column of B is 1:

norm(B(:, 1))
norm(B(:, 2))
norm(B(:, 3))
ans =
1
 
ans =
1
 
ans =
1

Compute an orthonormal basis of this matrix using 'real' to avoid complex conjugates:

syms a
A = [a 1; 1 a];
B = orth(A,'real')
B =
[ a/(a^2 + 1)^(1/2),    -(a^2 - 1)/((a^2 + 1)*((a^2 -...
 1)^2/(a^2 + 1)^2 + (a^2*(a^2 - 1)^2)/(a^2 + 1)^2)^(1/2))]
[ 1/(a^2 + 1)^(1/2), (a*(a^2 - 1))/((a^2 + 1)*((a^2 -...
 1)^2/(a^2 + 1)^2 + (a^2*(a^2 - 1)^2)/(a^2 + 1)^2)^(1/2))]

Compute an orthogonal basis of this matrix using 'skipNormalization':

syms a
A = [a 1; 1 a];
B = orth(A,'skipNormalization')
B =
[ a,               -(a^2 - 1)/(a*conj(a) + 1)]
[ 1, -(conj(a) - a^2*conj(a))/(a*conj(a) + 1)]

Compute an orthogonal basis of this matrix using 'skipNormalization' and 'real':

syms a
A = [a 1; 1 a];
B = orth(A,'skipNormalization','real')
B =
[ a,    -(a^2 - 1)/(a^2 + 1)]
[ 1, (a*(a^2 - 1))/(a^2 + 1)]

More About

expand all

Orthonormal Basis

An orthonormal basis for the range of matrix A is matrix B, such that:

  • B'*B = I, where I is the identity matrix.

  • The columns of B span the same space as the columns of A.

  • The number of columns of B is the rank of A.

Tips

  • Calling orth for numeric arguments that are not symbolic objects invokes the MATLAB orth function. Results returned by MATLAB orth can differ from results returned by orth because these two functions use different algorithms to compute an orthonormal basis. The Symbolic Math Toolbox™ orth function uses the classic Gram-Schmidt orthogonalization algorithm. The MATLAB orth function uses the modified Gram-Schmidt algorithm because the classic algorithm is numerically unstable.

  • Using 'skipNormalization' to compute an orthogonal basis instead of an orthonormal basis can speed up your computations.

Algorithms

orth uses the classic Gram-Schmidt orthogonalization algorithm.

Was this topic helpful?