ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 24 Dec 2018 10:29:23 -0600Computing heights of large degree algebraic numbershttp://ask.sagemath.org/question/44772/computing-heights-of-large-degree-algebraic-numbers/I have an irreducible polynomial of large degree (I would like to go up to degree ~1000), and I would like to compute the height of its roots. Currently I am doing this:
def irreducible_root_height(f):
K.<y> = NumberField(f)
h = y.global_height()
return h
This is rather slow because I have to construct the number field. Is there a way to find the height without constructing the number field?
I tried to use the functionality with general algebraic numbers, but there doesn't seem to be a way to define an arbitrary root of a polynomial in QQbar. It also looks like computing the height of something in QQbar works by computing a number field, so this wouldn't be any faster.vukovMon, 24 Dec 2018 10:29:23 -0600http://ask.sagemath.org/question/44772/Mapping between isomorphic NumberFieldshttp://ask.sagemath.org/question/42011/mapping-between-isomorphic-numberfields/ If I set up two NumberFields that differ only in the variable used in their defining polynomials, they don't report equal:
<pre>
sage: a=QQ['a'].0
sage: aRing = NumberField(a^2 + 1, 'a')
sage:
sage: b=QQ['b'].0
sage: bRing = NumberField(b^2 + 1, 'a')
sage:
sage: aRing is bRing
False
</pre>
This I can live with. But shouldn't I be able to convert elements between them?
<pre>
sage: aa=aRing.0
sage: bb=bRing.0
sage: bRing(aa)
TypeError: No compatible natural embeddings found for Number Field in a with defining polynomial b^2 + 1 and Number Field in a with defining polynomial a^2 + 1
</pre>
I can convert like this:
<pre>
sage: bbb = aa.polynomial()(bb)
sage: bbb.parent() == bRing
True
</pre>
...but this seems awkward, and requires defining an auxilary function if you want to pass it to map or map_coefficients.
Is this a bug? Should I report it on Sage's Trac, or is there a good reason for this?BrentBaccalaFri, 13 Apr 2018 15:35:18 -0500http://ask.sagemath.org/question/42011/Rewriting number field related Magma code in Sagehttp://ask.sagemath.org/question/41224/rewriting-number-field-related-magma-code-in-sage/I have the following Magma code, which I want to rewrite in Sage:
G := Sz(8);
T := CharacterTable(G);
M := GModule(T[2]:SparseCyclo := false);
N := AbsoluteModuleOverMinimalField(M);
Currently, I have something like this:
from sage.all import *
proof.arithmetic(False)
G = SuzukiGroup(8)
T = gap(G).CharacterTable()
print(gap.eval("Display(%s)"%T.name()))
Though, I do not know how to rewrite the rest in Sage. `Sz` in Magma is Suzuki group. The result of `M` here is `GModule M of dimension 14 over Cyclotomic Field of order 52 and degree 24`. Also, the result of `T[2]` in Magma is `T[2] = ( 14, -2, 2*zeta(4)_4, -2*zeta(4)_4, -1, 0, 0, 0, 1, 1, 1 )`. `AbsoluteModuleOverMinimalField` is defined [here](https://magma.maths.usyd.edu.au/magma/handbook/text/1038#11747).ninhoWed, 21 Feb 2018 14:39:53 -0600http://ask.sagemath.org/question/41224/Polynomials over number fieldshttp://ask.sagemath.org/question/38381/polynomials-over-number-fields/Below I define a polynomial ring K[s,t]. My goal is to compute the minors of a large matrix with entries in this ring.
var('x')
# K.<t> = NumberField(x^2-2)
K.<s,t> = NumberField([x^2-2,x^2-5])
R.<p0,p1,p2,p3,p4,p5> = K[]
M = Mat(R,10,10).random_element()
mins = M.minors(2)
This code works fine, but if I replace the last line with
mins = M.minors(7)
it fails with the error message
TypeError: no conversion to a Singular ring defined
Is it possible to avoid this error?coreyharrisMon, 24 Jul 2017 11:09:25 -0500http://ask.sagemath.org/question/38381/point on elliptic curvehttp://ask.sagemath.org/question/35677/point-on-elliptic-curve/ I have point `P=[-21,324]` on `E=ellipticCurve([0,0,0,-3267,45630])`. I noticed that point `P` can be written in different ways in each number field. For example in `Q(\sqrt{33})`, `P=[21+6*s, 54-42*s]` with `s^2=33`. And in complex numbers, `P=[15+36I,216-324I]` with `I^2=-1`. How can I find the `P` in different number fields. ShaMon, 21 Nov 2016 23:28:16 -0600http://ask.sagemath.org/question/35677/Defining a number field in sagehttp://ask.sagemath.org/question/34501/defining-a-number-field-in-sage/I know how to define a number field in sage by an irreducible polynomial over $\mathbb{Q}$, for example
sage: K.<a> = NumberField(x^3 - 2)
sage: a.minploy()
But how do I define any number field like $\mathbb{Q}(\sqrt{d_1},\sqrt{d_2})$ in sage, where $d_1$ and $d_2$ are two distinct squarefree integers? So how do I find the defining minimal polynomial of the field extension $\mathbb{Q}(\sqrt{d_1},\sqrt{d_2})$ over $\mathbb{Q}$?asksage_userWed, 17 Aug 2016 11:52:09 -0500http://ask.sagemath.org/question/34501/.subfields() not working in Sage 6.2; any workaround?http://ask.sagemath.org/question/33311/subfields-not-working-in-sage-62-any-workaround/ Running Sage 6.2, the .subfields() command is not working when applied to an octic number field. Is there any workaround?
(I'm using institutional resources, but they're having trouble updating the Sage version. Hence this question.)
The screenshot is linked below. (Awkward formatting because of the karma system; sorry!)
math.umd.edu/~bloom/sagescreenshot.png
samuelbloomTue, 03 May 2016 15:20:09 -0500http://ask.sagemath.org/question/33311/Define different embedding of a number fieldhttp://ask.sagemath.org/question/32517/define-different-embedding-of-a-number-field/Hi,
Let f(x) be an irreducible polynomial over $ZZ[x]$. We can define a number field
K.<a>= NumberField(f(x))
My question is how does one define all the embedding of K into the real or complex in Sage? Dianbin BaoTue, 09 Feb 2016 19:21:24 -0600http://ask.sagemath.org/question/32517/Finding p-adic valuations in high degree cyclotomic fieldshttp://ask.sagemath.org/question/26900/finding-p-adic-valuations-in-high-degree-cyclotomic-fields/I'm looking at a cyclotomic field ${\bf Q}(\mu_{p(p-1)})$ for $p$ a prime around 50 and so this field has fairly large degree. In this field, $p$ has ramification index $p$ and has $p-1$ primes sitting above it.
I'm trying to compute the valuation of an element in this field at any of these primes above $p$. Using commands like "primes_above" won't seem to work as the computer just hangs presumably because this extensions degree is just too big.
Questions:
1) Is there another way to compute $p$-adic valuations in this field?
2) Locally, this is only a $p$-th degree extension of ${\bf Q}_p$. So I created a p-adic field by using pAdicField(p).ext(1+(x+1)+(x+1)^2+...+(x+1)^(p-1)) to create this local p-th degree extension of Q_p. However, I can't find any way to map my global elements in ${\bf Q}(\mu_{p(p-1)})$ to this local field. Any ideas on how to proceed along these lines?
Robert PollackWed, 20 May 2015 08:47:43 -0500http://ask.sagemath.org/question/26900/subgroup of number field unit grouphttp://ask.sagemath.org/question/27274/subgroup-of-number-field-unit-group/I would like to be able to create subgroups of a unit group generated by given elements. I haven't, thus far, been able to find a way to make this work. The following doesn't work:
N.<a> = NumberField(x^3+2)
G = N.unit_group()
g = G.random_element()
G.subgroup([g])
Can anyone help me find a workaround?
(Note: it appears to be a bug, see [trac.sagemath.org/ticket/18863](http://trac.sagemath.org/ticket/18863), but I'm just looking for a workaround for now.)Kate StangeTue, 07 Jul 2015 17:59:55 -0500http://ask.sagemath.org/question/27274/Number field containing real/imaginary part of algebraic numberhttp://ask.sagemath.org/question/25822/number-field-containing-realimaginary-part-of-algebraic-number/I have a number field N with an embedding into C (e.g., NumberField(x^3+3, 'z', 0.7+1.2j)).
I would like the smallest number field N' that contains all Re(z) and Im(z) for z in N.
I would also like a mapping from x in N to (Re(x), Im(x) in N'xN' - or at least know what Re(z) and Im(z) is in N' for the generator z of N.
What is a good way of doing this?
I was thinking along the lines of N.composite_fields(NumberField(N.defining_polynomial, 'z', embedding=ComplexField()(N.gen_embedding()).conjugate()),both_maps=True). But I ran into http://trac.sagemath.org/ticket/14164 with this occasionally. Is there a better way of doing it?matthiasFri, 13 Feb 2015 12:47:13 -0600http://ask.sagemath.org/question/25822/embeddings in NumberFieldTower?http://ask.sagemath.org/question/25312/embeddings-in-numberfieldtower/I'm trying to do my calculations in a number field tower (or some equivalent), then get the results in real form (or anything that the graphics functions will take). I'm extending the rationals twice.
I've tried constructing the first with NumberField, then using extension, but apparently embedding isn't implemented in extension.
I've tried using NumberFieldTower, but I can't find an equivalent to embedding.
I've tried using NumberField(poly_1, poly_2) or QQ[poly_1, poly_1], but can't figure out how to assign an embedding or something equivalent.
I've considered trying to construct a field homomorphism from the field to the reals, but I don't know sage well enough to figure out if this is possible.
Is there some equivalent way of getting the values that I want?
Thanks!apeirogonSat, 20 Dec 2014 22:37:28 -0600http://ask.sagemath.org/question/25312/Homomorphisms for relative number fieldshttp://ask.sagemath.org/question/24173/homomorphisms-for-relative-number-fields/How can I define a homomorphism from a relative number field *K* (containing *F*)
to some other field *L* if I know where to send *K.gens()*?
**Example:**
F_pol = x^2-x-1
F = NumberField(F_pol, 'lam')
K_pol = x^2 + 4
K = F.extension(K_pol, 'e')
L = QQbar
lam_im = L(F_pol.roots()[1][0])
e_im = L(K_pol.roots()[1][0])
**Wrong result:**
K.hom([e_im], QQbar, check=False)
**What we want (not working):**
K.hom([e_im, lam_im], QQbar, check=False)
**A working solution (edit):**
K.Hom(L)(e_im, F.hom([lam_im], check=False))
New question/example: What if L is not exact?
----
x = PolynomialRing(QQ,'x').gen()
F_pol = x^3 - x^2 - 2*x + 1
F.<lam> = NumberField(F_pol, 'lam')
D = 4*lam^2 + 4*lam - 4
K_pol = x^2 - D
K = F.extension(K_pol, 'e')
L = CC
lam_im = F_pol.roots(L)[2][0]
e_im = F.hom([lam_im], check=False)(D).sqrt()
K.Hom(L)(e_im, F.hom([lam_im], check=False), check=False)
This gives the error:
TypeError: images do not define a valid homomorphismjjWed, 17 Sep 2014 20:36:11 -0500http://ask.sagemath.org/question/24173/pariError when computing discriminanthttp://ask.sagemath.org/question/9233/parierror-when-computing-discriminant/Consider the following piece of code:
Qx.<x> = PolynomialRing(Rationals())
K = NumberField(x^2+1, 'a')
OOK = K.ring_of_integers() #K.maximal_order() has same effect
OOa = OOK.extension(x^3+2, 'alpha'); OOa
This returns "`Univariate Quotient Polynomial Ring in alpha over Maximal Order in Number Field in a with defining polynomial x^2 + 1 with modulus alpha^3 + 2`". Why is this the case? I would have expected it to have the same effect as
Qx.<x> = PolynomialRing(Rationals())
00b = ZZ.extension([x^3+2,x^2+1], 'beta,b'); OOb
Namely, that it returns `"Relative Order in Number Field in beta with defining polynomial x^3 + 2 over its base field`".
Moreover, and perhaps more interestingly, when one tries to run the command `OOa.discriminant()` after the first piece of code, "`PariError: (5)`" is returned. Running the analogous command, `OOb.absolute_discriminant()` after the second piece of code, one gets -746496. I presume the fact that these two commands return different results is explained in [Quotients of Univariate Polynomial Rings](http://www.sagemath.org/doc/reference/sage/rings/polynomial/polynomial_quotient_ring.html "Quotients of Univariate Polynomial Rings") when it says
> The discriminant of the quotient polynomial ring need not equal the discriminant of the corresponding number field, since the discriminant of a number field is by definition the discriminant of the ring of integers of the number field.
even though we are not computing the discriminant of a number field in the second piece of code. However, why is a pariError returned when trying to compute the discriminant of `OOa`? Surely this must be somehow linked to the fact that the two blocks of code return completely different things. Is this indeed the case? Any help would be appreciated.
Leonhard MoosbruggerTue, 14 Aug 2012 02:58:15 -0500http://ask.sagemath.org/question/9233/elliptic curvehttp://ask.sagemath.org/question/8709/elliptic-curve/I am working with an elliptic curve over a pure cubic extension and I am interested in computing its L-function ( particularly its residue at s=1). Is it possible to extend functions on Sage such as lseries().dokchitser(), or anlist() to elliptic curve over number field ?
Thank youE37bSun, 12 Feb 2012 07:47:21 -0600http://ask.sagemath.org/question/8709/algebraic integer - PARI/GPhttp://ask.sagemath.org/question/9174/algebraic-integer-parigp/in sage you check if an algebraic number is an algebraic integer with is_integral. If I have a number(s) in an algebraic number field, and I want to check if it is an algebraic integers how do I do it in Pari/GP. Please help! Excuse me for using the forum for sage for questions about Pari/GP.paussseMon, 23 Jul 2012 12:11:12 -0500http://ask.sagemath.org/question/9174/Computing maximal orders in relative extensionshttp://ask.sagemath.org/question/9203/computing-maximal-orders-in-relative-extensions/As part of a project, I am translating some MAGMA code to SAGE. The relevant piece of code computes the maximal order of the relative extension of `Qa12`, a number field of degree 20, by the polynomial `y^2 - kappa12`:
subOrderK:=ext<OO | y^2-kappa12>;
subOrderK:=AbsoluteOrder(subOrderK);
D:=Discriminant(subOrderK);
for p in PrimeDivisors(D) do
subOrderK:=pMaximalOrder(subOrderK,p);
end for;
OOK:=subOrderK;
Here `OO` is the ring of integers (i.e. the maximal order) of `Qa12`.
As I did not see a way to translate this word for word (if I am missing something, please point it out), I tried a different approach. Here is my code (in SAGE):
L.<c> = Qa12.extension(y^2-kappa12)
L.<alpha> = L.absolute_field()
subOrderK = L.order(alpha)
D = subOrderK.discriminant()
for p in factor(D):
subOrderK = L.maximal_order(p[0])
OOK = subOrderK
Note that `y^2-kappa12` has coefficients coerced in `Qa12` and we make sure that it is indeed irreducible in `Qa12` (i.e. we make sure that `kappa12` is not the square of an element of `Qa12`).
You may notice immediately that my for-loop is a rather clumsy translation of the corresponding loop in the MAGMA code. I was hoping that SAGE would "remember" the previous value of `subOrderK`, thus having the same effect as the MAGMA-command `pMaximalOrder(subOrderK,p)`. However, my problem arises even earlier than that:
the number computed by `subOrderK.discriminant()` is absurdly huge - too big, in fact, for there to be any hope to factorise it in any reasonable amount of time.
The obvious alternative of simply writing
L.<c> = Qa12.extension(y^2-kappa12)
L.<alpha> = L.absolute_field()
OOK = L.maximal_order()
is also extremely time-intensive; I have not yet seen this finish.
I was hoping someone could help either with improving my code, or with a radically different approach to the problem.
NOTE: Though I have tried to make this question understandable, if some parts remain opaque, please do say so. I'll do my best to correct it. Leonhard MoosbruggerSat, 04 Aug 2012 04:33:43 -0500http://ask.sagemath.org/question/9203/How to check if a number field is a PIDhttp://ask.sagemath.org/question/9037/how-to-check-if-a-number-field-is-a-pid/Given a NumberField, is there a way to check if its ring of integers is a PID? This could be with a built in method, analogous to is_noetherian(), but if there's a more complicated way to do it that's good too.Alex CWed, 06 Jun 2012 12:28:05 -0500http://ask.sagemath.org/question/9037/Computing the order of an ideal in a ray class grouphttp://ask.sagemath.org/question/9127/computing-the-order-of-an-ideal-in-a-ray-class-group/Suppose $K$ is a number field, $\mathfrak{m}$ is a modulus of $K$, and $\mathfrak{a}$ is a given fractional ideal of $K$. SAGE can compute the ray class group $Cl_{\mathfrak{m}}(K)$. However, how can I find what element of the ray class group $\mathfrak{a}$ corresponds to? More specifically, I need to find the order of $\mathfrak{a}$ in $Cl_{\mathfrak{m}}$.
I can do this in MAGMA only when $\mathfrak{m}=(1)$, but does anyone know of a way to do this in SAGE?davidac897Tue, 03 Jul 2012 08:30:53 -0500http://ask.sagemath.org/question/9127/How does one tell if a number field contains a certain element?http://ask.sagemath.org/question/9094/how-does-one-tell-if-a-number-field-contains-a-certain-element/Suppose I have a number field K, in SAGE how would can see if something like \sqrt[4]{29} is contained in this number field?ghu198Tue, 19 Jun 2012 01:32:47 -0500http://ask.sagemath.org/question/9094/