Ask Your Question
0

quadratic form

asked 2017-06-30 01:17:32 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Write a function in Sage that accepts as input a symmetrical bilinear (not trivial) form B [caracterized by the associated matrix respect to the canonical base in R^n] and gives in output a vector subspace W ⊆ R^n such that: - Dim W is maximal - the restriction B|wxw has maximum rank

edit retag flag offensive close merge delete

Comments

This looks like homework.

If you want some help, you should ask more precise questions related to your research in solving those exercises, especially where you are locked.

tmonteil gravatar imagetmonteil ( 2017-06-30 10:35:27 +0200 )edit

i'm a sage beginner, i know what to do but i don't know how to implement it.. the idea is that i want to give in input a symmetrical nontrivial matrix A associated to the bilinear form B respect to the canonical base in R^n..then i want to obtain a subspace W⊆ R^n of maximal dimension such that the restriction B|wxw has max rank, in other words the matrix associated to this restriction has maximum rank and this condition occurs if kerW=[0].So i have to : 1. Give in input a matrix, 2. Declare the canonical basis of R^n and R 3. If B is the bilinear form and ei elements of the canonical base of R^n, i say that B(ei,ej)= A(i,j) with A(i,j) the i,j element of A 4. Obtain a subspace W ...(more)

ciao gravatar imageciao ( 2017-06-30 13:22:34 +0200 )edit

Please give us a symmetric matrix A to work with. Relevant code to initialize it can be found after typing ?matrix . Sample code for a matrix of my choice (maximal rank):

sage: A = matrix( QQ, 3, 3, [8,1,1, 1,8,1, 1,1,8 ] )
sage: A
[8 1 1]
[1 8 1]
[1 1 8]
sage: A.kernel()
Vector space of degree 3 and dimension 0 over Rational Field
Basis matrix:
[]
dan_fulea gravatar imagedan_fulea ( 2017-06-30 17:30:04 +0200 )edit

def function(Q):

#(Sylvester theorem to obtain a diagonalizing base)

n=Q.dim()

D=Q.rational_diagonal_form(return_matrix=True)[0]

M=Q.rational_diagonal_form(return_matrix=True)[1]

base=[M.column(i) for i in range(0,n)]

BASEpos=[]

BASEneg=[]

BASEnull=[]

for i in range(0,n):

    if D[i,i]>0: BASEpos=BASEpos+[1/sqrt(D[i,i])*base[i]]

    if D[i,i]<0: BASEneg=BASEneg+[1/sqrt(-D[i,i])*base[i]]

    if D[i,i]==0: BASEnull=BASEnull+[base[i]]

Base1= BASEpos+BASEneg      #(base without radical's vector to generate W)       

Base2= BASEpos+BASEneg+BASEnull

W=span(SR,B1)

return W

When i give as input a quadratic form Q such as Q=QuadraticForm(SR,4,[0,0,0,1,0,-1,0,0,0,0]) W=function(Q) the program give me a lot of errors

ciao gravatar imageciao ( 2017-07-01 03:03:26 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-07-02 04:33:15 +0200

dan_fulea gravatar image

The following works (over QQ instead of SR):

def f( Q ):
    D, M = Q.rational_diagonal_form( return_matrix=True )
    base = M.columns()

    BASEpos  = []
    BASEneg  = []
    BASEnull = []

    for j in range( 0, Q.dim() ):
        if   D[j,j] > 0 :    BASEpos  += [ 1/sqrt(  D[j,j] ) * base[j] ]
        elif D[j,j] < 0 :    BASEneg  += [ 1/sqrt( -D[j,j] ) * base[j] ]
        elif D[j,j] ==0 :    BASEnull += [                     base[j] ]

    return span( QQ, BASEpos + BASEneg )

Q = QuadraticForm( QQ, 4, [ 0,0,0,1,  0,-1,0,  0,0,  0 ] )
f( Q )

Results:

Vector space of degree 4 and dimension 4 over Rational Field
Basis matrix:
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-06-30 01:17:32 +0200

Seen: 601 times

Last updated: Jun 30 '17