Ask Your Question

Number field basis containing 1

asked 2018-04-24 14:21:01 -0500

eodorney gravatar image

In Sage, the default basis for a maximal order $O_K$ often does not contain the element $1$:

sage: QuadraticField(-3).ring_of_integers().basis()
[1/2*a + 1/2, a]

However, $1$ is always a primitive lattice vector in $O_K$. Is there an elegant way to produce a basis containing $1$?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-04-24 20:44:22 -0500

eodorney gravatar image

Found the answer! Basically the method is to reverse the coordinates on $O_K$ and re-echelonize the basis.

def basis_with_1(L):
  assert L.is_field();
  n =;
  R = matrix([[1 if i+j==n+1 else 0 for j in [1..n]] for i in [1..n]]);
  A = L.maximal_order().module().matrix();
  A = A*R;
  M = (ZZ^n).span_of_basis([vector(v) for v in A])
  A = matrix(M.echelonized_basis());
  A = R*A*R;
  return [L(v) for v in A]; 

sage: L = QuadraticField(-3)
sage: basis_with_1(L)
[1, 1/2*a + 1/2]
edit flag offensive delete link more


Congratulations; you can accept your own answer to mark your question as solved.

slelievre gravatar imageslelievre ( 2018-04-25 10:56:48 -0500 )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


Asked: 2018-04-24 14:21:01 -0500

Seen: 22 times

Last updated: Apr 24