4
$\begingroup$

Given a number field $K$, I would like to compute (in Sage) generators for the group of totally positive units of $K$.

Update: I've tried some code (details below), which I've received some help on in the comments. To clarify, my ideal would be to write up my own algorithm (rather than use code I found, as I discuss below).

I see reference to a strategy in the comments of the related question magma generators for unit group/ sage totally positive. The comment says that "it takes a bit of linear algebra mod 2 to construct a basis of totally positive units" from an existing set of fundamental units. I see some matrix algebra modulo 2 in the Pari code I found, but I don't know Pari well.

Question: Can anyone clarify the linear algebra to be done modulo 2, because then I could just go ahead and implement it in Sage myself?



Option 1: (existing Sage functions) The Sage function

K.S_units(S = []) 

computes a set of (not necessarily positive) generators. For $K$ of degree 3 or 4, I have successfully used this to get to a system of totally positive units. But I want an algorithm I can write for general degrees. I searched for other Sage functions that might help, without success. (Maybe I missed something?)

Option 2: (existing GP/Pari functions) I'm aware that I can use Pari in Sage. I've tried to adapt code on page 103 of the "User's Guide to PARI", link at https://math.mit.edu/~brubaker/PARI/PARIusers.pdf to arrive at the following (where I use %%gp to tell Sage to use GP for the cell):

%%gp bnf = bnfinit(x^3 + x^2 - 1) S = bnfsignunit(bnf) d = matsize(S) S = matrix(d[1],d[2], i,j, if (S[i,j] < 0, 1,0)) S = concat(S, vectorv(d[1],i,1)) K = lift(matker(S * Mod(1,2))) if(K, ex = mathnfmodid(K, 2), ex = 2*matid(d[1])) units = concat(bnf.tu[2], bnf.fu) result = vector(length(ex)-1, i, factorback([units, ex[,i+1]])) print(result) 

The code runs without errors. But I'm not getting expected results. For example, the shown polynomial of $x^3 + x^2 - 1$ gives me a result of $2x$ -- I note that this is just 2 times the unit returned by bnf.fu (which happens to already be totally positive). Meanwhile, I tried it on $x^4 + x - 1$ with result $(-2x, -x^3 - 1)$, neither of which is totally positive.

$\endgroup$
7
  • 2
    $\begingroup$ I do not know where you got that Pari code, but it is very old (for instance one now uses my() instead of local()). In particular, bnf.tufu does not exist. To make it work, simply replace bnf.tufu by concat(bnf.tu[2],bnf.fu). It should not give any more errors. $\endgroup$ Commented Nov 25, 2024 at 11:38
  • $\begingroup$ Thank you for your response/suggestion. I've edited my question with updates/clarification. Getting rid of tufu (and removing the calls to local() by not using function declarations) has produced code that doesn't raise errors. But I still don't get a basis of totally positive units, so something remains incorrect. I appreciate any insight or clarification on what is happening so that I can either (a) correct the above code, or (b) understand the algorithm itself so that I can code it in Sage myself. $\endgroup$ Commented Nov 25, 2024 at 17:44
  • 2
    $\begingroup$ Since you'r getting results like $2x$ and $-2x$ which are not units at all, while $x^2$ and $x^{-2}$ are positive units, you might be somehow computing $\sum_i c_i u_i$ instead of $\prod_i u_i^{c_i}$ (where $u_i$ are generators of the unit group). $\endgroup$ Commented Nov 25, 2024 at 17:53
  • 2
    $\begingroup$ Might be also useful to ask at: ask.sagemath.org/questions/scope:all/sort:activity-desc/page:1 $\endgroup$ Commented Nov 25, 2024 at 17:59
  • 4
    $\begingroup$ your factorback should not have [ ]: write factorback(units,ex[,i+1]). In any case, MO is not the forum to debug code, please write to the Sage or Pari maintainers instead. The result [Mod(x,x^3+x^2-1)] is correct in this example. $\endgroup$ Commented Nov 25, 2024 at 19:10

1 Answer 1

1
$\begingroup$

I'm answering my own question so that others might benefit from it.

Fix a number field $K$ with $r$ real emebeddings. Let $U = \langle u_1, \ldots, u_n \rangle$ denote the group of units and $U^+$ the group of totally positive units. We consider the map $$ \phi: U/U_{tors} \to (\mathbb{Z}/2 \mathbb{Z})^r $$ which takes a unit $u$ to its signature. We may regard $\phi$ as a matrix over $\mathbb{Z}/2 \mathbb{Z}$ with $n$ columns and $r$ rows, where the $k$-th column represents the signature of $u_k$. Moreover, we have $U^+/U_{tors}^+ = \mathrm{Ker}(\phi)$ and the short exact sequence $$ 1 \to U^+/U_{tors}^+ \to U/U_{tors} \to \mathrm{Im}(\phi) \to 0 $$ shows that the index of $U^+/U_{tors}^+$ in $U/U_{tors}$ is the rank of $\phi$.

Now, we seek $n$ independent elements of $U^+/U_{tors}^+$. If $\mathrm{rank}(\phi) = n$, then $$ U^+/U_{tors}^+ = \langle u_1^2, \ldots, u_n^2 \rangle. $$ In general, $n = \mathrm{rank}(\phi) + \mathrm{nullity}(\phi)$ and each element of $\mathrm{ker}(\phi)$ determines a totally positive product of some subset of $\{u_1, \ldots, u_n\}$. Then can generate $U^+/U_{tors}^+$ from a basis of $\mathrm{Null}(\phi)$ together with $\mathrm{rank}(\phi)$ squares of units from $\{u_1, \ldots, u_n \}$.

$\endgroup$
2
  • 2
    $\begingroup$ Is $\mathbb Z/_2\mathbb Z$ supposed to be $\mathbb Z/2\mathbb Z$? (It looks as if you've made the $2$ a subscript.) $\endgroup$ Commented Dec 15, 2024 at 21:30
  • $\begingroup$ Thanks -- updated! $\endgroup$ Commented Dec 16, 2024 at 12:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.