On Sep 24, 2008, at 4:42 AM, John Cremona wrote:

>
> 2008/9/24 mabshoff <[EMAIL PROTECTED]>:
>>
>>
>>
>> On Sep 24, 4:15 am, Raouf <[EMAIL PROTECTED]> wrote:
>>> Hi,
>>> I want to have a numerical value of a  Dirichlet character :
>>>
>>> I have this line code in my notebook:
>>>
>>> sage:
>>> G = DirichletGroup(21)
>>> chi = G.1;
>>> chi(23)
>>>
>>> evaluate:
>>> zeta6 - 1
>>>
>>> And when i want to use this value: zeta6 - 1 i have the error  
>>> message:
>>>
>>> G = DirichletGroup(21)
>>> chi = G.1;
>>> chi(23)
>>> B=13*chi(23)
>>> print float(B)
>>>
>>> error message:
>>>
>>> Traceback (most recent call last):
>>>   File "<stdin>", line 1, in <module>
>>>   File "/home/server2/nb1/sage_notebook/worksheets/fstthese/0/code/
>>> 6.py", line 10, in <module>
>>>     print float(B)
>>>   File "/home/server2/sage/local/lib/python2.5/site-packages/
>>> SQLAlchemy-0.4.6-py2.5.egg/", line 1, in <module>
>>>
>>> TypeError: float() argument must be a string or a number.
>>
>> Looks like a bug to me. The usual trick (at least in my book of using
>> n() does also not work):
>>
>> [EMAIL PROTECTED]:/scratch/mabshoff/release-cycle/sage-3.1.3.alpha1$ ./
>> sage
>> --------------------------------------------------------------------- 
>> -
>> | SAGE Version 3.1.3.alpha1, Release Date:  
>> 2008-09-24                |
>> | Type notebook() for the GUI, and license() for  
>> information.        |
>> --------------------------------------------------------------------- 
>> -
>>
>> sage: G = DirichletGroup(21)
>> sage: chi = G.1;
>> sage: chi(23)
>> zeta6 - 1
>> sage: B=13*chi(23)
>> sage: print float(B)
>> --------------------------------------------------------------------- 
>> ------
>> TypeError                                 Traceback (most recent call
>> last)
>>
>> /scratch/mabshoff/release-cycle/sage-3.1.3.alpha1/<ipython  
>> console> in
>> <module>()
>>
>> TypeError: float() argument must be a string or a number
>> sage: type(B)
>> <type
>> 'sage.rings.number_field.number_field_element_quadratic.NumberFieldEl 
>> ement_quadratic'>
>> sage: n(B)
>> --------------------------------------------------------------------- 
>> ------
>> TypeError                                 Traceback (most recent call
>> last)
>>
>> /scratch/mabshoff/release-cycle/sage-3.1.3.alpha1/<ipython  
>> console> in
>> <module>()
>>
>> /scratch/mabshoff/release-cycle/sage-3.1.3.alpha1/local/lib/python/
>> site-packages/sage/misc/functional.py in numerical_approx(x, prec,
>> digits)
>>    716             return
>> sage.rings.real_mpfr.RealField_constructor(prec)(x)
>>    717         except TypeError:
>> --> 718             return sage.rings.complex_field.ComplexField 
>> (prec)
>> (x)
>>    719
>>    720 n = numerical_approx
>>
>> /scratch/mabshoff/release-cycle/sage-3.1.3.alpha1/local/lib/ 
>> python2.5/
>> site-packages/sage/rings/complex_field.py in __call__(self, x, im)
>>    212             except AttributeError:
>>    213                 pass
>> --> 214         return complex_number.ComplexNumber(self, x, im)
>>    215
>>    216     def _coerce_impl(self, x):
>>
>> /scratch/mabshoff/release-cycle/sage-3.1.3.alpha1/complex_number.pyx
>> in sage.rings.complex_number.ComplexNumber.__init__ (sage/rings/
>> complex_number.c:2519)()
>>
>> TypeError: unable to coerce to a ComplexNumber
>> sage:
>>
>>
>> Can someone more knowledgeable in the area open a ticket?
>
> I'm not sure quite what the ticket would propose.  We could have a
> method n() for number field elements which maps the element into CC
> using the first available complex embedding and a precision given by a
> prec parameter.  But I think number theorists are more likely to want
> to have control over their embeddings, as in my sample solution.

Under the new coercion model (not ported yet, but high on the todo  
list), one can create number fields with default embeddings, which  
may make sense to do here.

- Robert


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

Reply via email to