#12269: coercion and conversion for absolute_field
-----------------------------+----------------------------------------------
   Reporter:  mstreng        |          Owner:  davidloeffler                   
                                           
       Type:  enhancement    |         Status:  new                             
                                           
   Priority:  major          |      Milestone:  sage-5.0                        
                                           
  Component:  number fields  |       Keywords:  coercion conversion 
absolute_field number field structure relative absolute
Work_issues:                 |       Upstream:  N/A                             
                                           
   Reviewer:                 |         Author:                                  
                                           
     Merged:                 |   Dependencies:                                  
                                           
-----------------------------+----------------------------------------------

Old description:

> {{{
> sage: x = var('x')
> sage: K1.<a1> = CyclotomicField(11)
> sage: K2.<a2> = K1.extension(x^2 - 3)
> sage: K3.<a3> = K2.extension(x^2 + 1) # Let's make a big relative number
> field
> sage: t=a1+6*a2+a3*a1                 # with a complicated element.
> sage: L = K3.absolute_field('b')
> sage: L(t)
> # The code at #11869 takes 12 seconds to compute roots of a
> # polynomial, and then doesn't use them.
> # TypeError: No compatible natural embeddings found for Number Field in b
> with .... and Complex Lazy Field
> sage: L.structure()                   # However, the correct conversion
> map is available and works almost instantly
> #(Isomorphism map:... , Isomorphism map: ...)
> sage: L.structure()[1](t)
> # big output
> sage: L.gen() + t                     # It would be good if one of the
> structure maps is a coercion, but they aren't at the moment
> # TypeError: unsupported operand parent(s) for '+': ....
> sage: K3(L.gen())                     # There are similar problems in the
> other direction
> # TypeError: Cannot coerce element into this number field
> sage: L.structure()[0](L.gen())       # for which the structure maps also
> work.
> # a3 - a2 + a1
> }}}
>
> So to do:
>
>  * make both structure maps into conversions (this ticket)
>  * make one of the structure maps into a coercion (this ticket)
>  * move the "compatible embedding" code of #11869 to the beginning of the
> method, to avoid unnecessary root-finding (#12270)

New description:

 {{{
 sage: x = var('x')
 sage: K1.<a1> = CyclotomicField(11)
 sage: K2.<a2> = K1.extension(x^2 - 3)
 sage: K3.<a3> = K2.extension(x^2 + 1) # Let's make a big relative number
 field
 sage: t=a1+6*a2+a3*a1                 # with a complicated element.
 sage: L = K3.absolute_field('b')
 sage: L(t)
 # The code at #11869 takes 12 seconds to compute roots of a
 # polynomial, and then doesn't use them.
 # TypeError: No compatible natural embeddings found for Number Field in b
 with .... and Complex Lazy Field
 sage: L.structure()                   # However, the correct conversion
 map is available and works almost instantly
 #(Isomorphism map:... , Isomorphism map: ...)
 sage: L.structure()[1](t)
 # big output
 sage: L.gen() + t                     # It would be good if one of the
 structure maps is a coercion, but they aren't at the moment
 # TypeError: unsupported operand parent(s) for '+': ....
 sage: K3(L.gen())                     # There are similar problems in the
 other direction
 # TypeError: Cannot coerce element into this number field
 sage: L.structure()[0](L.gen())       # for which the structure maps also
 work.
 # a3 - a2 + a1
 }}}

 So this ticket is meant to:

  * make both structure maps into conversions
  * maybe make one or both of the structure maps into a coercion

 Speeding up #11869 is not really related and is #12270.

--

Comment(by mstreng):

 Replying to [comment:7 mstreng]:
 > {{{structure()[1]}}} cannot be a coercion, because it would lead to non-
 commuting diagrams of coercions.

 Actually, maybe it is the coercion between O to P that shouldn't be there!
 All of the following maps are natural
 {{{ O <--> M <-- K <--> L --> N <--> P }}}
 and a map between O and P sending generator to generator does not commute
 with the abovementioned natural maps.

 Some more about O and P:
 {{{
 sage: O
 Number Field in e with defining polynomial x^4 - 10*x^2 + 1
 sage: P
 Number Field in e with defining polynomial x^4 - 10*x^2 + 1
 sage: O is P
 False
 sage: O == P
 True
 sage: RR(O.structure()[1].domain().base_field().gen())
 -1.41421356237309
 sage: RR(P.structure()[1].domain().base_field().gen())
 1.41421356237309
 }}}
 O and P are really different, I don't understand True for "==" here. Is
 that a bug?
 {{{
 sage: K is L
 False
 sage: K == L
 False
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12269#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to