Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One equality for polynomials denotes three equations for coefficients

R.<x1,x2> = PolynomialRing(SR)
Vx=matrix([x1,x2])
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
var('a00,a01,a11')                   
A=matrix([ [a00,a01],[a01,a11] ])    # symmetry!
VtAV=Vx*A*(Vx.transpose()) 
p2=(VtAV-p)[0][0]           # scalar polynomial lhs-rhs
eq=[u==0 for u in p2.coefficients()] # equations
solve(eq,[a00,a01,a11])              # solving

[[a00 == 2, a01 == -2, a11 == 5]]

One equality for polynomials denotes three equations for coefficients

R.<x1,x2> = PolynomialRing(SR)
Vx=matrix([x1,x2])
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
var('a00,a01,a11')                   
A=matrix([ [a00,a01],[a01,a11] ])    # symmetry!
VtAV=Vx*A*(Vx.transpose()) 
p2=(VtAV-p)[0][0]           # scalar polynomial lhs-rhs
eq=[u==0 for u in p2.coefficients()] # equations
solve(eq,[a00,a01,a11])              # solving

[[a00 == 2, a01 == -2, a11 == 5]]

Shortcut:

R.<x1,x2> = PolynomialRing(SR)
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
q=Q.from_polynomial(p);
q.Gram_matrix()

[ 2 -2]
[-2  5]

One equality for polynomials denotes three equations for coefficients

R.<x1,x2> = PolynomialRing(SR)
Vx=matrix([x1,x2])
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
var('a00,a01,a11')                   
A=matrix([ [a00,a01],[a01,a11] ])    # symmetry!
VtAV=Vx*A*(Vx.transpose()) 
p2=(VtAV-p)[0][0]           # scalar polynomial lhs-rhs
eq=[u==0 for u in p2.coefficients()] # equations
solve(eq,[a00,a01,a11])              # solving

[[a00 == 2, a01 == -2, a11 == 5]]

Shortcut:

Q=QuadraticForm(QQ,2)    
R.<x1,x2> = PolynomialRing(SR)
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
q=Q.from_polynomial(p);
q.Gram_matrix()

[ 2 -2]
[-2  5]

One equality for polynomials denotes three equations for coefficients

R.<x1,x2> = PolynomialRing(SR)
Vx=matrix([x1,x2])
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
var('a00,a01,a11')                   
A=matrix([ [a00,a01],[a01,a11] ])    # symmetry!
VtAV=Vx*A*(Vx.transpose()) 
p2=(VtAV-p)[0][0]           # scalar polynomial lhs-rhs
eq=[u==0 for u in p2.coefficients()] # equations
solve(eq,[a00,a01,a11])              # solving

[[a00 == 2, a01 == -2, a11 == 5]]

Shortcut:

Q=QuadraticForm(QQ,2)    
R.<x1,x2> = PolynomialRing(SR)
PolynomialRing(QQ)
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
q=Q.from_polynomial(p);
q.Gram_matrix()

[ 2 -2]
[-2  5]

One equality for polynomials denotes three equations for coefficients

R.<x1,x2> = PolynomialRing(SR)
Vx=matrix([x1,x2])
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
var('a00,a01,a11')                   
A=matrix([ [a00,a01],[a01,a11] ])    # symmetry!
VtAV=Vx*A*(Vx.transpose()) 
p2=(VtAV-p)[0][0]           # scalar polynomial lhs-rhs
eq=[u==0 for u in p2.coefficients()] # equations
solve(eq,[a00,a01,a11])              # solving

[[a00 == 2, a01 == -2, a11 == 5]]

Shortcut:

Q=QuadraticForm(QQ,2)    
R.<x1,x2> = PolynomialRing(QQ)
p=2*(x1^2) - 4*x1*x2 + 5*(x2^2)
q=Q.from_polynomial(p);
q=QuadraticForm.from_polynomial(p);
q.Gram_matrix()

[ 2 -2]
[-2  5]