On Dec 22, 2008, at 6:20 AM, John Cremona wrote:

> You can do K(r.lift()), but it would be nicer if this was handled by
> coercion magic.

This isn't really a coercion issue per se, it's a question of adding  
another case to the _element_constructor_ method of number fields. Do  
we want coercion here, i.e. should someone be able to write r + K.gen 
()? If so, would it be the most natural to put the result into K or  
the quotient ring?

> I don't know how that could be done in Sage, but
> mathematically it would make sense whenever the defining polynomial of
> K divided that of R.
>
> John
>
> 2008/12/22 Alex Ghitza <aghi...@gmail.com>:
>> Hi,
>>
>> While working with number fields, I've run into this:
>>
>> sage: K.<a> = NumberField(x^8+1)
>> sage: R = K.polynomial_quotient_ring()
>> sage: r = R.random_element()
>>
>> And now the point of this: I would like to think of r as an  
>> element of K.
>> However:
>>
>> sage: K(r)
>> --------------------------------------------------------------------- 
>> ------
>> TypeError                                 Traceback (most recent  
>> call last)
>>
>> /opt/sage-3.2.1/devel/sage-main/sage/<ipython console> in <module>()
>>
>> /opt/sage-3.2.1/local/lib/python2.5/site-packages/sage/structure/ 
>> parent.so
>> in sage.structure.parent.Parent.__call__ (sage/structure/parent.c: 
>> 3645)()
>>
>> /opt/sage-3.2.1/local/lib/python2.5/site-packages/sage/structure/ 
>> coerce_maps.so
>> in sage.structure.coerce_maps.DefaultConvertMap_unique._call_
>> (sage/structure/coerce_maps.c:2778)()
>>
>> /opt/sage-3.2.1/local/lib/python2.5/site-packages/sage/structure/ 
>> coerce_maps.so
>> in sage.structure.coerce_maps._call_ (sage/structure/coerce_maps.c: 
>> 2685)()
>>
>> /opt/sage-3.2.1/local/lib/python2.5/site-packages/sage/rings/ 
>> number_field/number_field.pyc
>> in _element_constructor_(self, x)
>>    1422                 raise ValueError, "vector must be of  
>> length equal to
>> the degree of this number field"
>>    1423             return sum([ x[i]*self.gen(0)**i for i in
>> range(self.degree()) ])
>> -> 1424         return self._coerce_non_number_field_element_in(x)
>>    1425
>>    1426     def _coerce_from_str(self, x):
>>
>> /opt/sage-3.2.1/local/lib/python2.5/site-packages/sage/rings/ 
>> number_field/number_field.pyc
>> in _coerce_non_number_field_element_in(self, x)
>>    1520         except (TypeError, AttributeError), msg:
>>    1521             pass
>> -> 1522         raise TypeError, type(x)
>>    1523
>>    1524     def _coerce_map_from_(self, R):
>>
>> TypeError: <class
>> 'sage.rings.polynomial.polynomial_quotient_ring_element.PolynomialQuo 
>> tientRingElement'>
>>
>>
>>
>> Since K and R are canonically isomorphic, it seems to me that K(r)  
>> should
>> really work.  Any thoughts?  Is there another way I can get r into K?
>>
>> Best,
>> Alex
>>
>>
>> --
>> Alex Ghitza -- Lecturer in Mathematics -- The University of  
>> Melbourne --
>> Australia -- http://www.ms.unimelb.edu.au/~aghitza/
>>
>>>
>>
>
> >


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to