 
 
 
 
 
 
RE: Generating Two Unit Orthogonal Vectors
- To: mathgroup at smc.vnet.net
- Subject: [mg36448] RE: Generating Two Unit Orthogonal Vectors
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Sat, 7 Sep 2002 02:54:04 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
David Park replied with
----------------
Daniel Lichtblau has pointed out that NullSpace does not generally give
orthogonal vectors. Therefore the routines that depended upon that were in
error. He says that it does give orthogonal vectors when the input vector
contains approximate numbers. For graphical purposes this will be good
enough for me. Therefore I modify Ted's routine to
OrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /;
        (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) :=
    #/Sqrt[#.#] & /@ NullSpace[{vect}// N]
----------------
Lets see what NullSpace does with approximate complex vectors.
In[1]:=
   v1 = {1.0 I, 0.0, 0.5 I, 0.0, 1.0};
   v2 = {0.0, 2.0, 1.0 I, 2.0, 0.5};
   {v3,v4,v5} = NullSpace[{v1,v2}]
Out[3]=
   {{-0.730153 + 0.*I, 0. - 0.138254*I, 0.250585 + 0.*I, 0. - 0.138254*I, 0.
+ 0.60486*I}, 
     {0. + 0.*I, -0.515861 + 0.*I, 0. + 0.457321*I, 0.687357 + 0.*I, 0.22866
+ 0.*I}, 
     {0. + 0.*I, 0.510406 + 0.*I, 0. + 0.740442*I, -0.23274 + 0.*I, 0.370221
+ 0.*I}}
--------
In the next line we see NullSpace returned vectors that are orthogonal to
the vectors we gave NullSpace.
In[4]:=
   {v1.v3, v1.v4, v1.v5, v2.v3, v2.v4, v2.v5}//Chop
Out[4]=
   {0, 0, 0, 0, 0, 0}
----------
However, the vectors returned aren't orthogonal to each other.
In[5]:=
   {v3.v4, v3.v5, v4.v5}//Chop
Out[5]=
   {0.229195*I, 0.371087*I, -0.677239}
---------
I suppose an OrthogonalUnitVectors function that uses NullSpace should 
  (1)  Only accept real valued vectors.  
  (2) Ensure NullSpace is given approximate vectors.
------
Regards,
   Ted Ersek

