Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28495 views
License: GPL3
ubuntu2004
Function: bnfisprincipal
Section: number_fields
C-Name: bnfisprincipal0
Prototype: GGD1,L,
Help: bnfisprincipal(bnf,x,{flag=1}): bnf being output by bnfinit, gives
 [e,t], where e is the vector of exponents on the class group generators and
 t is the generator of the resulting principal ideal. In particular x is
 principal if and only if e is the zero vector. flag is optional, whose
 binary digits mean 1: output [e,t] (only e if unset); 2: increase precision
 until t can be computed (do not insist if unset); 4: return t in
 factored form (compact representation).
Doc: $\var{bnf}$ being the \sidx{principal ideal}
 number field data output by \kbd{bnfinit}, and $x$ being an ideal, this
 function tests whether the ideal is principal or not. The result is more
 complete than a simple true/false answer and solves a general discrete
 logarithm problem. Assume the class group is $\oplus (\Z/d_i\Z)g_i$
 (where the generators $g_i$ and their orders $d_i$ are respectively given by
 \kbd{bnf.gen} and \kbd{bnf.cyc}). The routine returns a row vector $[e,t]$,
 where $e$ is a vector of exponents $0 \leq e_i < d_i$, and $t$ is a number
 field element such that
 $$ x = (t) \prod_i  g_i^{e_i}.$$
 For \emph{given} $g_i$ (i.e. for a given \kbd{bnf}), the $e_i$ are unique,
 and $t$ is unique modulo units.

 In particular, $x$ is principal if and only if $e$ is the zero vector. Note
 that the empty vector, which is returned when the class number is $1$, is
 considered to be a zero vector (of dimension $0$).
 \bprog
 ? K = bnfinit(y^2+23);
 ? K.cyc
 %2 = [3]
 ? K.gen
 %3 = [[2, 0; 0, 1]]          \\ a prime ideal above 2
 ? P = idealprimedec(K,3)[1]; \\ a prime ideal above 3
 ? v = bnfisprincipal(K, P)
 %5 = [[2]~, [3/4, 1/4]~]
 ? idealmul(K, v[2], idealfactorback(K, K.gen, v[1]))
 %6 =
 [3 0]

 [0 1]
 ? % == idealhnf(K, P)
 %7 = 1
 @eprog

 \noindent The binary digits of \fl mean:

 \item $1$: If set, outputs $[e,t]$ as explained above, otherwise returns
 only $e$, which is easier to compute. The following idiom only tests
 whether an ideal is principal:
 \bprog
   is_principal(bnf, x) = !bnfisprincipal(bnf,x,0);
 @eprog

 \item $2$: It may not be possible to recover $t$, given the initial accuracy
 to which the \kbd{bnf} structure was computed. In that case, a warning is
 printed and $t$ is set equal to the empty vector \kbd{[]\til}. If this bit is
 set, increase the precision and recompute needed quantities until $t$ can be
 computed. Warning: setting this may induce \emph{lengthy} computations, and
 the result may be too large to be physically representable in any case.
 You should consider using flag $4$ instead.

 \item $4$: Return $t$ in factored form (compact representation),
 as a small product of $S$-units for a small set of finite places $S$,
 possibly with huge exponents. This kind of result can be cheaply mapped to
 $K^*/(K^*)^\ell$ or to $\C$ or $\Q_p$ to bounded accuracy and this is usually
 enough for applications. Explicitly expanding such a compact representation
 is possible using \kbd{nffactorback} but may be \emph{very} costly.
 The algorithm is guaranteed to succeed if the \kbd{bnf} was computed using
 \kbd{bnfinit(,1)}. If not, the algorithm may fail to compute a huge
 generator in this case (and replace it by \kbd{[]\til}). This is orders of
 magnitude faster than flag $2$ when the generators are indeed large.

Variant: Instead of the above hardcoded numerical flags, one should
 rather use an or-ed combination of the symbolic flags \tet{nf_GEN} (include
 generators, possibly a place holder if too difficult), \tet{nf_GENMAT}
 (include generators in compact form) and
 \tet{nf_FORCE} (insist on finding the generators, a no-op if \tet{nf_GENMAT}
 is included).