2.1. Theory A. Orthogonal Sets: Any Orthogonal Set Is Linearly Independent
2.1. Theory A. Orthogonal Sets: Any Orthogonal Set Is Linearly Independent
2.1. Theory A. Orthogonal Sets: Any Orthogonal Set Is Linearly Independent
Theory
a. Orthogonal sets
Let V be a vector space with an inner product.
Definition. Nonzero vector v , v …, v ∈ V form an orthogonal set if they are orthogonal to each
1 2 k
other: (v , v ) = 0 for i j.
i j
If, in addition, all vector are of unit norm, , then v , v …, v is called an orthonormal set.
1 2, k
Let , v ∈ V, v 0. Then p = is the orthogonal projection of the vector onto the vector v.
That is, the remainder o = x – p is orthogonal to v.
If v v v is an orthogonal set of vector then
1, 2, … , n
Let
Then v , v ,...,v
1 2 n.
2.2. Progression
Step 1: Fill the input of vector in array V . To be precise V = {v ,v ,v ,…} is a basis of the space
1 1 1 2 3
R(n).
Step 2: Computing the orthogonal basis:
Step 3: Let u = u ;
1 1
Step 4: Calculate u = 2 , u= 3
Step 5: Calculate u . k
Step 7: E =
1 ; E=
2 ;…..
2.3. Matlab code
1st way:
function U = Gram_Schmidt(V1)
%V1 is a basis in the space R(n) including these vectors you input
V = transpose(V1);%transposing these vectors
m = size(V,1);
k = size(V,2);
U = zeros(m,k);
U(:,1) = V(:,1)/sqrt(V(:,1)'*V(:,1)); %calculate the orthonormal basis of column 1
disp('Orthogonal basis: ');
disp(V(:,1)); %Computing the orthogonal basis of the space spanned the vectors
for i = 2:n %Because u1 = v1, take i runs starting from 2 to n.
U(:,i) = V(:,i);
for j = 1:i-1
U(:,i) = U(:,i) - ( U(:,j)'*U(:,i) )/( U(:,j)'*U(:,j) )*U(:,j); %calculate the orthogonal basis
end
disp(U(:,i));
U(:,i) = U(:,i)/sqrt(U(:,i)'*U(:,i));%calculate the orthonormal basis
end
disp('Orthonormal basis: ');
end
Example 1:
Example 2:
Example 3:
2nd way :
function U = K(v)
%v is a basis in the space R(n) including these vectors you
input
v=[3 4 5;9 2 5; -7 3 4]
V = transpose(v); );%transposing these vectors
m = size(V,1);
n = size(V,2);
U=zeros(m,n);
U(:,1)=V(:,1);
U(:,1) = V(:,1)/sqrt(V(:,1)'*V(:,1)); %calculate the orthonormal
basis of column 1
disp(V(:,1));
for i=2:n %Because u1 = v1, take i runs starting from 2 to k.
s=V(:,i);
for j=1 :i-1
s=s-(dot(V(:,i),U(:,j))/dot(U(:,j),U(:,j)))*U(:,j);
%calculate the orthogonal basis
end
U(:,i)=s;
disp(U(:,i));
U(:,i) = U(:,i)/sqrt(U(:,i)'*U(:,i)); %calculate the
orthogomal basis
end
Give the same answer as example 1