`> `**with(linalg):**

Warning, new definition for norm

Warning, new definition for trace

`> `**r1 := vector([1,2,3]);**

`> `**r2 := vector([1,1,0]);**

`> `**r3 := vector([1,0,0]);**

`> `**GramSchmidt({r1,r2,r3});**

`> `**#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.**

`> `**eigenvalues(M);**

`> `**# 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)) )**
`> `**eigenvalues(1.0*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[1]),conjugate(u[2]),
conjugate(u[3])])); end;**

`> `**# Let us also define a norm function**

`> `**nrm:=proc(v) sqrt(multiply(v, M,
vector([conjugate(v[1]), conjugate(v[2]), conjugate(v[3])]))); 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)):**

`> `**evalm(v1);**

`> `**evalm(v2);**

`> `**evalm(v3);**

`> `**# Let us verify that we got the
right result! (try just g(v1, v2) to see why we put this evala in front...)**

`> `**evala(nrm(v1));evala(nrm(v2));evala(nrm(v3));**

`> `**evala(g(v1, v2));evala(g(v1, v3));evala(g(v2,
v3));**

`> `**#DONE!!**