Ask Your Question
0

Calculating an Orthonormal Basis

asked 2012-06-07 01:31:06 -0600

BrianLoudon gravatar image

updated 2012-06-07 01:31:35 -0600

Hi, I'm still quite inexperienced with Sage at the moment, so forgive me if this is a basic issue. I am trying to produce an orthonormal basis, I have created the orthogonal complement to my original basis by taking its left nullspace using kernel() I now want to use gram_schmidt() to produce a normalised version. I am unsure however what ring my input matrix should be over. QQbar won't work for me, but I am worried that the RDF result I get will not retain the linear independence that I need, as it says in the documentation for gram_schmidt() that under RDF, "no attempt is made to recognize linear dependence with approximate calculations" My input matrix is the following;

[   0   -1    0    0    1    0    0    0    0    0    0    0]
[-1/2    0    0 -1/2    0    0    1    0    0    0    0    0]
[-1/2   -1    0  1/2    0    0    0    1    0    0    0    0]
[-1/2    0    0 -1/2    0    0    0    0    0    1    0    0]
[ 1/2   -1    0 -1/2    0    0    0    0    0    0    1    0]
[   0    0   -1    0    0   -1    0    0    1    0    0    1]

if I change the ring of this matrix to RDF, gram_schmidt() runs but the inexact entries of -0.0 and what is clearly 1/sqrt(2) are not so useful.

    [               0.0    -0.408248290464     0.353553390593
-0.288675134595     0.353553390593 -1.32686526214e-17]
[    0.707106781187 -8.67632788532e-17     0.353553390593
-1.40946282423e-17    -0.353553390593 -1.72861506093e-17]
[              -0.0                0.0                0.0  
1.9952420559e-17  3.41114374126e-17               -0.5]
[              -0.0    -0.408248290464    -0.353553390593   
-0.288675134595    -0.353553390593  4.70626515093e-17]
[   -0.707106781187  3.12521276219e-17     0.353553390593 
6.96057794736e-17    -0.353553390593 -1.72861506093e-17]
[              -0.0                0.0               -0.0               
0.0                0.0               -0.5]
[              -0.0     0.816496580928  5.51587855252e-17   
-0.288675134595 -7.45998857306e-17  1.68969994439e-17]
[              -0.0                0.0    -0.707106781187 
9.67672224796e-18  5.13672629661e-18                0.0]
[              -0.0                0.0               -0.0               
0.0                0.0                0.5]
[              -0.0                0.0               -0.0    
0.866025403784 -2.24700900248e-17  -1.5111067779e-17]
[              -0.0                0.0               -0.0               
0.0     0.707106781187  1.24852656425e-17]
[              -0.0                0.0               -0.0               
0.0                0.0                0.5]

Does anybody know where I've gone wrong here? Is there another more reliable method for computing an orthonormal basis that I could use? Thanks again for putting up with a newbie!

best regards

Brian

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-06-07 03:37:41 -0600

achrzesz gravatar image
A=matrix(QQ,
[[  0,   -1,    0,    0,    1,    0,    0,    0,    0,    0,    0,    0],
[-1/2,    0,    0, -1/2,    0,    0,    1,    0,    0,    0,    0,    0],
[-1/2,   -1,    0,  1/2,    0,    0,    0,    1,    0,    0,    0,    0],
[-1/2,    0,    0, -1/2,    0,    0,    0,    0,    0,    1,    0,    0],
[ 1/2,   -1,    0, -1/2,    0,    0,    0,    0,    0,    0,    1,    0],
[   0,    0,   -1,    0,    0,   -1,    0,    0,    1,    0,    0,    1]])

G, M = A.gram_schmidt()     # no normalization in G
g=G*G.transpose()
gsqrt=g.apply_map(sqrt)
q=gsqrt.inverse()
Gr=q*G                      # Gr is the orthonormal version of G
print Gr*Gr.transpose()     # check the orthonormality of Gr
print (M*gsqrt)*Gr==A       # check if  A=(M*gsqrt)*Gr
edit flag offensive delete link more

Comments

Nice! [Live version](http://aleph.sagemath.org/?z=eJyVkTFvgzAQhXf_iidlAURo6e6ByVOGzBGKLErAamzDYUVNf30xpBGUVKSWdTrdvfvuyc64lo7UZ7Dfx-xwAF5jANvUxzG_xWXlz5j3pG368jbvLCvr1Clp4ukRaYX3D08rVE_CwtOTpBlvIM06y3d_6ifSPA8ZEzF24MiSiqQ-dkWt1bsLQi_ABsb2l7Q8qy_plDVQBoJVXEQicSRN19iuDEJWdS05XiWyac7Xo5ZN4Asha_nQSZS5lDQoBfE2Enh4NhAE1cHVJSy52o674Wf9cnvqlzekjOuF9yQSNPVyIxV1WXz8Jil3HSA_w8EuGvyFPYPz7G5jHFYnIONTzTfwlqV3)

Jason Grout gravatar imageJason Grout ( 2012-06-07 03:56:32 -0600 )edit

wow, thanks!

BrianLoudon gravatar imageBrianLoudon ( 2012-06-07 04:37:59 -0600 )edit

might take me a while to understand it fully, but great thanks!

BrianLoudon gravatar imageBrianLoudon ( 2012-06-07 04:38:37 -0600 )edit

@BrianLoudon - don't forget to upvote it if you like it :) and accept it if it fulfills your needs.

kcrisman gravatar imagekcrisman ( 2012-06-07 09:03:57 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-06-07 01:31:06 -0600

Seen: 665 times

Last updated: Jun 07 '12