Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

LAB EXPERIMENT - 5

Problem Statement:
1. Given a set of n vector in a vector space . Orthogonalize them using Gram-Schmidt procedure. 2. Let A be a matrix of linearly independent vectors. Using Gram-Schmidt process reduce A to a form A=QR. Q=Orthonormal column R=Invertible upper triangular matrix In mathematics, particularly linear algebra and numerical analysis, the GramSchmidt process is a method for ortho-normalising a set of vectors in an inner product space, most commonly the Euclidean space Rn. The GramSchmidt process takes a finite, linearly independent set S = {v1, , vk} for k n and generates an orthogonal set S = {u1, , uk} that spans the same k-dimensional subspace of Rn as S.

Algorithm: 1. Enter the matrix A. 2. Let where independent columns are. 3. Find orthogonal columns corresponding to . 4. Find corresponding to . 5. Now matrix . 6. Similarly find matrix R.

Report by Amit Kumar Singh for TIM-LAB, M.Tech. (VST), Deptt. Of ECE,SOE, Shiv Nadar University

Flow Chart

Report by Amit Kumar Singh for TIM-LAB, M.Tech. (VST), Deptt. Of ECE,SOE, Shiv Nadar University

Matlab program: central code:


clear all; clc; fid=fopen(matrix,r); A=fread(fid,[3,3]; fclose(fid); [m,n]=size(A); Q=zeros(m,n); R=zeros(m,n); for j=1:n; v=A(:,j); for i=1:j-1 R(i,j)=Q(:,i)'*A(:,j); v=v-R(i,j)*Q(:,i); end R(j,j)=sqrt(innerproduct(v, v)); Q(:,j)=v/R(j,j); end disp(' matrix Q'); disp(Q); disp(' matrix R') disp(R);

Report by Amit Kumar Singh for TIM-LAB, M.Tech. (VST), Deptt. Of ECE,SOE, Shiv Nadar University

Function for innerproduct:

function [c] = innerproduct(A, B) % this function is used to find the inner product of two row vector c=0; n=size(A,2); m=size(B,2); if (n==m) for i=1:n c=c+A(i)*B(i); end else disp(' matrix dimension not match '); end end

Output matrix Q 1.0000 -1.0000 -1.0000 4.0000 -4.1364 -4.1376 1.0000 -1.0000 -0.9342 matrix R 1.0000 24.0000 39.0000 0 22.0000 -39.9545 0 0 75.9545

Report by Amit Kumar Singh for TIM-LAB, M.Tech. (VST), Deptt. Of ECE,SOE, Shiv Nadar University

Result: A set of n vector in a vector space


procedure.

were Orthogonalized using Gram-Schmidt

Report by Amit Kumar Singh for TIM-LAB, M.Tech. (VST), Deptt. Of ECE,SOE, Shiv Nadar University

You might also like