Warning, new definition for norm
Warning, new definition for trace> #The function GramSchmidt computes a list or set of orthogonal vectors from a given list or set of linearly independent vectors, using the Gram-Schmidt orthogonalization process. The vectors given must be linearly independent, otherwise the vectors returned will also be dependent. The vectors returned are not normalized. Note that this function always assumes that we are dealing with the standard inner product.
> r1 := vector([1,2,3]);
> r2 := vector([1,1,0]);
> r3 := vector([1,0,0]);
> #To calculate in a general case, we may proceed as follows. Let
> M:= matrix([[6, 2-3*I, 2*I], [2+3*I, 3, 0], [-2*I, 0, 4]]);
> # We would like to verify that this defines an inner product. First
> evalm(M -transpose(conjugate(M)));
> # So the matrix is hermitian. Is it positive definite? For that one needs to check that the eigenvalues are all positive real numbers. We shall discuss later on in the course what are these 'eigenvalues'. For now, just apply the following function checking that you get positive reals in reply.
> # This is hard to read. So let us
make Maple treat it in an approximate form by multiplying M by 1.0
(or use the command evalf(eigenvalues(M)) )
> #Clearly these are positive reals (and the imaginary part is a result of the approximation procedure used to find the roots).
> #We would like to define now a function whose input is two vectors and whose output is the inner product of these vectors, w.r.t. M.
> g:= proc(v, u) multiply(v, M, vector([conjugate(u),conjugate(u), conjugate(u)])); end;
> # Let us also define a norm function
> nrm:=proc(v) sqrt(multiply(v, M, vector([conjugate(v), conjugate(v), conjugate(v)]))); end;
> #Thus, for example the inner product of (1, 1, 0) and (2*I, 0, 0) is found by
> v:=vector([1, 1,0]);u:=vector([2*I, 0, 0]);g(v,u);
> # and the norm of (1, -1, 3) by
> nrm(vector([1, -1, 3]));
> # Let us find an orthonormal basis by applying Gram-Schmidt to the standard basis.
> s1:= vector([1, 0, 0]); s2 := vector([0, 1, 0]);s3 := vector([0, 0, 1]);
> v1:= evalm(s1/nrm(s1)):
> w2:= evalm(s2 - g(s2,v1)*v1):
> v2:= evalm(w2/nrm(w2)):
> w3:= evalm(s3-g(s3,v1)*v1-g(s3,v2)*v2):
> v3:= evalm(w3/nrm(w3)):
> # Let us verify that we got the right result! (try just g(v1, v2) to see why we put this evala in front...)
> evala(g(v1, v2));evala(g(v1, v3));evala(g(v2, v3));