Hauptinhalt

orth

R2026b

Orthonormal basis for range of symbolic matrix

Description

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

example

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

example

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.

example

orth(A,"real","skipnormalization") computes a non-normalized orthogonal basis using a real scalar product in the orthogonalization process.

example

Examples

Compute Orthonormal Basis

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 Real Orthonormal Basis

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 Orthogonal Basis by Skipping Normalization

Compute an orthogonal basis of this matrix using "skipnormalization". The lengths of the resulting vectors (the columns of matrix B) are not required to be 1

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 Real Orthogonal Basis

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)]

Input Arguments

collapse all

Input, specified as a symbolic matrix.

More About

collapse all

Tips

  • Calling orth with numeric arguments that are not symbolic objects invokes the MATLAB orth function. The results returned by the MATLAB orth function might differ from those returned by the Symbolic Math Toolbox™ orth function. The reason is that orthogonalizations are generally not unique, and these two functions use different algorithms to compute an orthonormal basis.

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

Version History

Introduced in R2013a

See Also

| | | |