Ask Your Question

BrianLoudon's profile - activity

2017-03-11 05:27:06 -0600 received badge  Famous Question (source)
2016-05-11 15:00:36 -0600 received badge  Famous Question (source)
2015-04-14 04:07:08 -0600 received badge  Notable Question (source)
2014-12-12 11:09:41 -0600 received badge  Notable Question (source)
2014-01-31 20:53:45 -0600 received badge  Popular Question (source)
2013-07-02 08:09:35 -0600 received badge  Popular Question (source)
2012-06-07 04:38:37 -0600 commented answer Calculating an Orthonormal Basis

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

2012-06-07 04:37:59 -0600 commented answer Calculating an Orthonormal Basis

wow, thanks!

2012-06-07 01:31:35 -0600 received badge  Editor (source)
2012-06-07 01:31:06 -0600 asked a question Calculating an Orthonormal Basis

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

2012-05-01 06:27:35 -0600 received badge  Student (source)
2012-05-01 01:10:57 -0600 commented question A question on symbolic Matrices - unexpected Decimals in algebraic entry

fantastic! thanks! I cast the result of mag^2 to an int and got the results I was expecting, great stuff! This has allowed me to verify my calc against an example and I can use this as a basis for what I'm trying to build up. Many thanks!

2012-05-01 00:22:55 -0600 asked a question A question on symbolic Matrices - unexpected Decimals in algebraic entry

Firstly, I'd just like to say that I am starting out with Sage adn Python at the moment, really impressed by the power of Sage and its potential! I am coming at this from an engineering and C++ background, and am currently trying to look at an engineering problem using some matrix linear algebra. I am setting up a from of stiffness matrix and am trying to extract the symbolic eigenvalues and eigenvectors from this. The stiffness matrix below is generated through a few different matrix multiplication operations, based on node and connectivity matrices. Despite trying to define these as being "SR" rings, I seem to end up with entries like (b + 1.0g + 1.0s) rather than the (b + g + s) I was expecting. I suspect this is due to me not understanding rings properly and how to apply them. I have tried the explanations in the Sage documentation, can anybody recommend some further reading or tutorials on this, because it does seem to be a vital topic in getting to grips with Sage?

I enclose my code below, in case anybody can spot a glaringly stupid thing that I've done...

many thanks,

Brian

N = matrix(QQ,[[1,0,-1,0],[0,1,0,-1]])

C = matrix(QQ,[[-1,0,1,0],[0,-1,0,1],[-1,1,0,0],[0,-1,1,0],[0,0,-1,1],[1,0,0,-1]])

D = C.transpose()

space = N.nrows()


M = N*D
M
II = identity_matrix(QQ,space)
b,s,g = var('b s g')
numMembers = M.ncols()

LVector  = II

#loop through members to create LVector
for i in range(numMembers):


    m1 = M.matrix_from_columns([i])
    mt = m1.transpose()
    mag = m1.norm()
    Coeff = m1*mt/(mag^2)
    size = m1.norm()

    if i<2:
        #for bars
        L = -g*(II - Coeff) + b*Coeff
    else:
        L = g*(II - Coeff) + s*Coeff

    L.factor()

    if i == 0:
        LVector = L
    else:
        LVector = LVector.block_sum(L)
    print L.str()

print LVector.str()

Pre = D.tensor_product(II)
Post = C.tensor_product(II)
K = Pre*LVector
K = K*Post

Ks = K.change_ring(SR)
print Ks.str()

Eigen = K.eigenvectors_left()
print Eigen.str()