NumberFieldEmbedding gets confused with relative number fields

44 views
Skip to first unread message

Ilia

unread,
Mar 22, 2021, 10:19:09 AM3/22/21
to sage-support
Hello,

When defining a NumberFieldEmbedding for a relative number field and then applying it to the field generator, I get a result which is different from the specified generator image:

sage: K.<sqrt2> = QuadraticField(2, embedding=1.414)
sage: L.<s> = K.extension(x^3 + (sqrt2/2 + 1/3)*x^2 + (2*sqrt2/5+3/7)*x - 1)
sage: my_embedding = NumberFieldEmbedding(L, QQbar, L.relative_polynomial().roots(QQbar)[0][0])
sage: my_embedding
Generic morphism:
  From: Number Field in s with defining polynomial x^3 + (1/2*sqrt2 + 1/3)*x^2 + (2/5*sqrt2 + 3/7)*x - 1 over its base field
  To:   Algebraic Field
  Defn: s -> 0.5407496381556470?
sage: my_embedding.gen_image()
0.5407496381556470?
sage: my_embedding(L.gen())
0.01354690080260168?

Of course, I would have expected the last two results to be equal. My configuration: SageMath version 9.1, running on Ubuntu 18.04.3 LTS (64-bit).

This seems to stem from Sage somehow confusing the relative generator of L (over K) with the absolute generator of L (over QQ), even though I am not completely sure.

Should I open a trac ticket for this?

slelievre

unread,
Apr 23, 2021, 7:33:36 PM4/23/21
to sage-support

2021-03-22 14:19:09 UTC, Ilia:
>
> When defining a NumberFieldEmbedding for a relative number
> field and then applying it to the field generator, I get a result
> which is different from the specified generator image:

sage: from sage.rings.number_field.number_field_morphisms import NumberFieldEmbedding

sage: K.<sqrt2> = QuadraticField(2, embedding=1.414)
sage: L.<s> = K.extension(x^3 + (sqrt2/2 + 1/3)*x^2 + (2*sqrt2/5+3/7)*x - 1)
sage: my_embedding = NumberFieldEmbedding(L, QQbar, L.relative_polynomial().roots(QQbar)[0][0])
sage: my_embedding
Generic morphism:
From: Number Field in s with defining polynomial x^3 + (1/2*sqrt2 + 1/3)*x^2 + (2/5*sqrt2 + 3/7)*x - 1 over its base field
To: Algebraic Field
Defn: s -> 0.5407496381556470?
sage: my_embedding.gen_image()
0.5407496381556470?
sage: my_embedding(L.gen())
0.01354690080260168?

> Of course, I would have expected the last two results
> to be equal. My configuration: SageMath version 9.1,
> running on Ubuntu 18.04.3 LTS (64-bit).
>
> This seems to stem from Sage somehow confusing the relative
> generator of L (over K) with the absolute generator of L (over QQ),
> even though I am not completely sure.
>
> Should I open a trac ticket for this?

Hi Ilia,

Could this have to do with one of the following existing tickets?

- Sage Trac ticket 22008
  complex_embedding on relative number fields is inconsistent with the base field

- Sage Trac ticket 17524
  polynomial for relative number field elements

Thanks for your report in any case.
Hope this can be solved.  --Samuel

Vincent Delecroix

unread,
Apr 24, 2021, 3:45:41 PM4/24/21
to sage-s...@googlegroups.com
Hello Ilia,

It is even more broken than that (on 9.3.rc4)

sage: K.<sqrt2> = QuadraticField(2, embedding=1.414)
sage: L.<s> = K.extension(x^3 + (sqrt2/2 + 1/3)*x^2 + (2*sqrt2/5+3/7)*x - 1)
sage: roots = L.relative_polynomial().roots(QQbar, multiplicities=False)


sage: from sage.rings.number_field.number_field_morphisms import
NumberFieldEmbedding
sage: phi0 = NumberFieldEmbedding(L, QQbar, roots[0])
sage: phi1 = NumberFieldEmbedding(L, QQbar, roots[1])
sage: phi2 = NumberFieldEmbedding(L, QQbar, roots[2])
sage: phi0(sqrt2)
-0.9806353488506175?
sage: phi1(sqrt2)
-0.9728180790542797? + 0.006537273218425100?*I
sage: phi2(sqrt2)
-0.9728180790542797? - 0.006537273218425100?*I

My guess is that NumberFieldEmbedding was not designed to work with
relative extensions at all.

Best
Vincent

Vincent Delecroix

unread,
Apr 24, 2021, 3:51:27 PM4/24/21
to sage-s...@googlegroups.com
At least on 9.3.rc4 it is fixed by using instead

sage: K.<sqrt2> = QuadraticField(2, embedding=AA(2).sqrt())
sage: L.<s> = K.extension(x^3 + (sqrt2/2 + 1/3)*x^2 + (2*sqrt2/5+3/7)*x - 1)
sage: phi0 = hom(L, QQbar, roots[0])
sage: phi1 = hom(L, QQbar, roots[1])
sage: phi2 = hom(L, QQbar, roots[2])
sage: phi0(sqrt2)
1.414213562373095?
sage: phi1(sqrt2)
1.414213562373095? + 0.?e-17*I
sage: phi2(sqrt2)
1.414213562373095? + 0.?e-17*I

Ilia

unread,
Apr 28, 2021, 9:32:52 AM4/28/21
to sage-support
On Saturday, April 24, 2021 at 1:33:36 AM UTC+2 slelievre wrote:
> Could this have to do with one of the following existing tickets?
>
> - Sage Trac ticket 22008
>  complex_embedding on relative number fields is inconsistent with the base field

This is indeed related: it also involves Sage mistaking the extension [L:K] for the extension [L:QQ]. But it does not seem to be the exact same problem: I am not sure that fixing ticket 17524 would automatically fix the problem I am describing here. Well, it *might*; but the only way to be sure is to actually pinpoint the problem - and this would involve a complex hunt through a lot of different code files that I (being a total newbie to Sage development) do not feel like doing right now.

> - Sage Trac ticket 17524
>   polynomial for relative number field elements

This one, OTOH, seems a bit different: in this one, there is no confusion between [L:K] and [L:QQ], but simply a problem of consistency between the chosen embedding of K when taken by itself and the chosen embedding of K when seen as a subfield of L.


On Saturday, April 24, 2021 at 9:51:27 PM UTC+2 vdelecroix wrote:
At least on 9.3.rc4 it is fixed by using instead

sage: K.<sqrt2> = QuadraticField(2, embedding=AA(2).sqrt())
sage: L.<s> = K.extension(x^3 + (sqrt2/2 + 1/3)*x^2 + (2*sqrt2/5+3/7)*x - 1)
sage: phi0 = hom(L, QQbar, roots[0])
sage: phi1 = hom(L, QQbar, roots[1])
sage: phi2 = hom(L, QQbar, roots[2])
sage: phi0(sqrt2)
1.414213562373095?
sage: phi1(sqrt2)
1.414213562373095? + 0.?e-17*I
sage: phi2(sqrt2)
1.414213562373095? + 0.?e-17*I

For what it is worth, in my config (version 9.1), this gives a "ValueError: relations do not all (canonically) map to 0 under map determined by images of generators". So, OK, presumably this has been fixed in the meanwhile. But anyway, where can I find documentation for the "hom" method?

Assuming it works, OK, thank you, it is a good workaround. Still, in the meanwhile, I think that something needs to be done about NumberFieldEmbedding: it should either be fixed, be deprecated, or at least the documentation should be updated to signal that it does not work in relative fields. So I guess I will now try to open a ticket.

Samuel Lelièvre

unread,
Apr 28, 2021, 11:04:13 AM4/28/21
to Sage-support
2021-04-28 15:32 UTC+2, Ilia:
> On Saturday, April 24, 2021 at 1:33:36 AM UTC+2 slelievre wrote:
> > Could this have to do with one of the following existing tickets?
> >
> > - Sage Trac ticket 22008
> > complex_embedding on relative number fields is inconsistent with the base field
> > https://trac.sagemath.org/ticket/22008
>
> This is indeed related: it also involves Sage mistaking the extension [L:K]
> for the extension [L:QQ]. But it does not seem to be the exact same
> problem: I am not sure that fixing ticket 17524 would automatically
> fix the problem I am describing here. Well, it *might*; but the only way
> to be sure is to actually pinpoint the problem - and this would involve
> a complex hunt through a lot of different code files that I (being a total
> newbie to Sage development) do not feel like doing right now.
>
> > - Sage Trac ticket 17524
> > polynomial for relative number field elements
> > https://trac.sagemath.org/ticket/17524
>
> This one, OTOH, seems a bit different: in this one, there is no confusion
> between [L:K] and [L:QQ], but simply a problem of consistency between
> the chosen embedding of K when taken by itself and the chosen
> embedding of K when seen as a subfield of L.

I agree.

> On Saturday, April 24, 2021 at 9:51:27 PM UTC+2 vdelecroix wrote:
>>
>> At least on 9.3.rc4 it is fixed by using instead
>>
>> sage: K.<sqrt2> = QuadraticField(2, embedding=AA(2).sqrt())
>> sage: L.<s> = K.extension(x^3 + (sqrt2/2 + 1/3)*x^2 + (2*sqrt2/5+3/7)*x - 1)
>> sage: phi0 = hom(L, QQbar, roots[0])
>> sage: phi1 = hom(L, QQbar, roots[1])
>> sage: phi2 = hom(L, QQbar, roots[2])
>> sage: phi0(sqrt2)
>> 1.414213562373095?
>> sage: phi1(sqrt2)
>> 1.414213562373095? + 0.?e-17*I
>> sage: phi2(sqrt2)
>> 1.414213562373095? + 0.?e-17*I
>
>
> For what it is worth, in my config (version 9.1), this gives
> a "ValueError: relations do not all (canonically) map to 0
> under map determined by images of generators". So, OK,
> presumably this has been fixed in the meanwhile.

You can try Sage 9.2 at SageCell:

https://sagecell.sagemath.org

> But anyway,
> where can I find documentation for the "hom" method?

sage: hom?
sage: hom??
sage: browse_sage_doc(hom)

sage: Hom?
sage: Hom??
sage: browse_sage_doc(Hom)

https://doc.sagemath.org/html/en/reference/categories/sage/categories/homset.html
https://doc.sagemath.org/html/en/reference/categories/sage/categories/homsets.html

> Assuming it works, OK, thank you, it is a good workaround.
> Still, in the meanwhile, I think that something needs to be
> done about NumberFieldEmbedding: it should either be
> fixed, be deprecated, or at least the documentation should
> be updated to signal that it does not work in relative fields.
> So I guess I will now try to open a ticket.

Sounds good. --Samuel

slelievre

unread,
Apr 29, 2021, 9:55:00 AM4/29/21
to sage-support
Samuel:
>
> Ilia:
> >
> > So I guess I will now try to open a ticket.
>
> Sounds good. --Samuel

This is now tracked at

- Sage Trac ticket 31755
  NumberFieldEmbedding does not work with relative number fields
  https://trac.sagemath.org/ticket/31755

Thanks for opening the ticket! Hope this gets solved soon!
Reply all
Reply to author
Forward
0 new messages