Question: Gram-Schmidt problem


Use the Gram-Schmidt process to transform the basis

{Vector(3, {(1) = 0, (2) = 1, (3) = 1}),

Vector(3, {(1) = 1, (2) = 1, (3) = 1}),

Vector(3, {(1) = 1, (2) = 2, (3) = 3})}

for the Euclidean space R3 into an orthonormal basis for R3


Show 3D result.
 
This is what was given to solve the problem, but it is not working.
 
 
> GramSchmidt2 := proc () 
local M, rows, numV, v, seqL, lstL, i, j, vlength; 
numV := nargs; 
 
print('Original set'); 
    seqL := NULL; 
if type(args[1], Matrix) and numV = 1 then 
    M := args[1]; 
   numV := LinearAlgebra[ColumnDimension](M); 
   rows := LinearAlgebra[RowDimension](M);
 
   if rows < numV then 
       WARNING("input  is a set of Linearly Dependent Vectors") end if; 
   for i to numV do 
      vi := Column(M, i); 
      vi:= convert(vi, Vector); 
      seqL := seqL, vi :
end do: 
else 
  rows := nops(args[1]); 
  if rows < numV then 
         WARNING("input  is a set of Linearly Dependent Vectors"); 
end if; 
 for i to numV do vi:= args[i]; 
vi := convert(vi, Vector); 
if nops(vi) ≠ rows then 
error "the lenght of inputed Vectors sould be the same";
 end if; 
seqL := seqL, vi;
end do;
 end if; 
print([seqL]); 
print('Orthogonal set'); 
if Norm(vi, 2) ≠ 0 then 
seqL := vi;
else
 seqL := NULL;
 end if; 
for j from 2 to numV do 
for i to j-1 do 
if Norm(vi, 2) ≠ 0 then 
vj := vj-Proj(vi, vj);
 end if;
 end do; 
if Norm(vj, 2) ≠ 0 then 
seqL := seqL, vj;
end if;
 end do; 
print([seqL]); 
print('Orthonormal set'); 
seqL := NULL; 
for j to numV do 
if Norm(vj, 2) ≠ 0 then 
vj:= vj/Norm(vj, 2); 
seqL := seqL, vj;
end if;
 end do; 
print([seqL]); 
lstL := [seqL]; 
return lstL;
 end proc;
> Proj := proc (u, v) 
return (u.v)*u/(u.u);
end proc;
> w1 :=<(0,1,1)> ;
> w2 := <(1,1,1)>;
> w3 := <(1,2,3)>;
>GramSchmidt2(w1, w2, w3)
 
> vectordisplay := proc () 
local numV, v, a, seqA, lstL, i, j; 
numV := nargs; with(plots); 
setoptions(color = red, scaling = constrained, style = line); 
numV := nargs; 
seqA := NULL; 
for i to numV do
vi:= args[i]; 
vi:= convert(vi, Vector); 
if nops(vi) = 3 then 
ai:= arrow(vi, shape = arrow, axes = normal) else error "only display 3d vectors" end if; 
seqA := seqA, ai;
end do; 
display(seqA);
 end proc;
> w1 := ;

> w2 := ;

> w3 := ;

> printf("Before ... "); 
vectordisplay(w1, w2, w3); 
printf("Normalizing..."); 
 
lstW := GramSchmidt2(w1, w2, w3); 
printf("After..."); 
vectordisplay(op(lstW));
Please Wait...