Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem starts before the norm - it is not clear to me how to create a variable taking values in K. All these fail, for example:

sage: a=var('a') ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'
sage: a=var('a',domain=QQ) ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'
sage: a=var('a',domain=K) ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'

Does anyone have a suggestion?

The problem starts before I think this is a solution - please tell me if the norm - result is what you wanted to calculate:

sage: var(','.join(['x%d'%i for i in range(K.degree())]))
(x0, x1, x2, x3)
sage: sum([eval('x%d'%i)*(g^i).matrix() for i in range(K.degree())])
[      x0       x1       x2       x3]
[     -x3  x0 - x3  x1 - x3  x2 - x3]
[-x2 + x3      -x2  x0 - x2  x1 - x2]
[-x1 + x2 -x1 + x3      -x1  x0 - x1]
sage: _.determinant()
x0^4 - x0^3*x1 - x0^3*x2 - x0^3*x3 + x0^2*x1^2 + 2*x0^2*x1*x2 + 2*x0^2*x1*x3 + x0^2*x2^2 - 3*x0^2*x2*x3 + x0^2*x3^2 - x0*x1^3 - 3*x0*x1^2*x2 + 2*x0*x1^2*x3 + 2*x0*x1*x2^2 - x0*x1*x2*x3 - 3*x0*x1*x3^2 - x0*x2^3 + 2*x0*x2^2*x3 + 2*x0*x2*x3^2 - x0*x3^3 + x1^4 - x1^3*x2 - x1^3*x3 + x1^2*x2^2 + 2*x1^2*x2*x3 + x1^2*x3^2 - x1*x2^3 - 3*x1*x2^2*x3 + 2*x1*x2*x3^2 - x1*x3^3 + x2^4 - x2^3*x3 + x2^2*x3^2 - x2*x3^3 + x3^4

In any case, it is not clear would be nice to me how be able to create have a variable taking values in K. All these fail, for example:

sage: a=var('a') ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'
sage: a=var('a',domain=QQ) ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'
sage: a=var('a',domain=K) ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'

Does anyone have a suggestion?

I think this is a solution - please tell me if the result is indeed what you wanted to calculate:

sage: var(','.join(['x%d'%i for i in range(K.degree())]))
(x0, x1, x2, x3)
sage: sum([eval('x%d'%i)*(g^i).matrix() for i in range(K.degree())])
[      x0       x1       x2       x3]
[     -x3  x0 - x3  x1 - x3  x2 - x3]
[-x2 + x3      -x2  x0 - x2  x1 - x2]
[-x1 + x2 -x1 + x3      -x1  x0 - x1]
sage: _.determinant()
x0^4 - x0^3*x1 - x0^3*x2 - x0^3*x3 + x0^2*x1^2 + 2*x0^2*x1*x2 + 2*x0^2*x1*x3 + x0^2*x2^2 - 3*x0^2*x2*x3 + x0^2*x3^2 - x0*x1^3 - 3*x0*x1^2*x2 + 2*x0*x1^2*x3 + 2*x0*x1*x2^2 - x0*x1*x2*x3 - 3*x0*x1*x3^2 - x0*x2^3 + 2*x0*x2^2*x3 + 2*x0*x2*x3^2 - x0*x3^3 + x1^4 - x1^3*x2 - x1^3*x3 + x1^2*x2^2 + 2*x1^2*x2*x3 + x1^2*x3^2 - x1*x2^3 - 3*x1*x2^2*x3 + 2*x1*x2*x3^2 - x1*x3^3 + x2^4 - x2^3*x3 + x2^2*x3^2 - x2*x3^3 + x3^4

In any case, it would be nice to be able to have a variable taking values in K. All these fail, for example:

sage: a=var('a') ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'
sage: a=var('a',domain=QQ) ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'
sage: a=var('a',domain=K) ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'

Does anyone have a suggestion?

I think this is a solution - please tell me if the result is indeed what you wanted to calculate:

sage: K.<g> = NumberField(1+x+x^2+x^3+x^4)
sage: var(','.join(['x%d'%i for i in range(K.degree())]))
(x0, x1, x2, x3)
sage: sum([eval('x%d'%i)*(g^i).matrix() for i in range(K.degree())])
[      x0       x1       x2       x3]
[     -x3  x0 - x3  x1 - x3  x2 - x3]
[-x2 + x3      -x2  x0 - x2  x1 - x2]
[-x1 + x2 -x1 + x3      -x1  x0 - x1]
sage: _.determinant()
x0^4 - x0^3*x1 - x0^3*x2 - x0^3*x3 + x0^2*x1^2 + 2*x0^2*x1*x2 + 2*x0^2*x1*x3 + x0^2*x2^2 - 3*x0^2*x2*x3 + x0^2*x3^2 - x0*x1^3 - 3*x0*x1^2*x2 + 2*x0*x1^2*x3 + 2*x0*x1*x2^2 - x0*x1*x2*x3 - 3*x0*x1*x3^2 - x0*x2^3 + 2*x0*x2^2*x3 + 2*x0*x2*x3^2 - x0*x3^3 + x1^4 - x1^3*x2 - x1^3*x3 + x1^2*x2^2 + 2*x1^2*x2*x3 + x1^2*x3^2 - x1*x2^3 - 3*x1*x2^2*x3 + 2*x1*x2*x3^2 - x1*x3^3 + x2^4 - x2^3*x3 + x2^2*x3^2 - x2*x3^3 + x3^4

In any case, it would be nice to be able to have a variable taking values in K. All these fail, for example:

sage: a=var('a') ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'
sage: a=var('a',domain=QQ) ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'
sage: a=var('a',domain=K) ; a*g
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Number Field in g with defining polynomial x^4 + x^3 + x^2 + x + 1'

Does anyone have a suggestion?