Opened 11 years ago

Last modified 7 months ago

#5355 new enhancement

QQbar should have a coercion from number fields with embedding

Reported by: cwitty Owned by: cwitty
Priority: major Milestone: sage-wishlist
Component: coercion Keywords: qqbar, coercion
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by pbruin)

If a number field comes with an embedding into the complex numbers, QQbar should allow coercions (or at least conversions) from that number field. For example:

sage: K.<a> = NumberField(x^3 - x + 1, embedding=-1.32)
sage: QQbar.coerce_map_from(K)
Ring morphism:
  From: Number Field in a with defining polynomial x^3 - x + 1
  To:   Algebraic Field
  Defn: a |--> -1.324717957244746?

Currently, this map can already be created using K.hom([QQbar(a)]) (see #13041).

Change History (7)

comment:1 Changed 10 years ago by cremona

This should not be hard. Here is what I propose:

  • Given a number field K and an emebedding of K into RR or CC, return the corresponding embedding of K into QQbar. This just requires selecting from K.embeddings(QQbar) the one which maps K.gen() to the element of QQbar closest to the image of K.gen() under the given embedding. As a variation, if the given embedding was into RR then the output could be an embedding into AA>
  • As a default we could give no embedding and then use K.gen().complex_embedding() instead.

Using the default there would be a coercion possible from K to QQbar; but the first version would allow the user flexibility.

comment:2 Changed 6 years ago by mmezzarobba

  • Report Upstream set to N/A

Related: #12715

comment:3 follow-up: Changed 4 years ago by vdelecroix

We do have

sage: K.<a> = NumberField(x^3 - 7, embedding=AA(7)**(1/3))
sage: AA.has_coerce_map_from(K)
True
sage: K.<a> = NumberField(x^3 - 7, embedding=QQbar(7)**(1/3) * QQbar.zeta(3))
sage: QQbar.has_coerce_map_from(K)
True

Isn't it enough? What should be simplified is to automatized the embedding into AA/QQbar. And it is more or less the purpose of #19356.

comment:4 Changed 12 months ago by pbruin

  • Description modified (diff)

comment:5 Changed 7 months ago by jipilab

  • Keywords qqbar coercion added

comment:6 Changed 7 months ago by nbruin

There are memory-leak implications on this: Coercions are normally cached on the codomain (in this case QQbar). Having a coercion from a number field K to QQbar would imply a reference from QQbar to K. Some effort is made to not make that reference a strong one right from the start (this is why the coercion framework tries to use weak references to the domain), but you'd have to test this quite carefully. Thanks to the complicated interactions with the (weak) dictionaries, I expect that some indirect memory leaks would be introduced.

comment:7 in reply to: ↑ 3 Changed 7 months ago by mkoeppe

Replying to vdelecroix:

We do have

sage: K.<a> = NumberField(x^3 - 7, embedding=AA(7)**(1/3))
sage: AA.has_coerce_map_from(K)
True
sage: K.<a> = NumberField(x^3 - 7, embedding=QQbar(7)**(1/3) * QQbar.zeta(3))
sage: QQbar.has_coerce_map_from(K)
True

Isn't it enough? What should be simplified is to automatized the embedding into AA/QQbar. And it is more or less the purpose of #19356.

To automate the embedding, what should be the interface, perhaps something like this?

K.<a> = NumberField(x^3 - 7, embedding=1.9, embedding_field=AA)
Note: See TracTickets for help on using tickets.