On Dec 29, 9:40 am, "John Cremona" <john.crem...@gmail.com> wrote:
> There really are two different issues here. The one which William and
> Michael concentrate on is that adding .n(100) to a 53-bit complex
> number does not increase its precision in any meaningful sense, it
> just pads with 47 bits of 0.
>
> But the second point is to do with Georg's original observation that
> sage: type(CC(1/3 + 0.0*I))
> <type 'sage.rings.complex_number.ComplexNumber'>
> sage: type(CC(1/3 + 0.0*I).n(100))
> <type 'sage.rings.real_mpfr.RealNumber'>
>
> or perhaps more clearly,
> sage: z = CC(1/3 + 0.0*I)
> sage: type(z)
> <type 'sage.rings.complex_number.ComplexNumber'>
> sage: type(z.n(10))
> <type 'sage.rings.real_mpfr.RealNumber'>
>
> so that the return type of .n() is real.
>
> John Cremona
Yeah, that is kind of obvious now that I look at it again :)
Maybe the docstring out to be cleaned up and clearly state that the
returned type is a real since it currently does not:
sage: a.n?
Type: builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form: <built-in method n of
sage.rings.complex_number.ComplexNumber object at 0x7f23df3c44d0>
Namespace: Interactive
Docstring:
Return a numerical approximation of x with at least prec
bits of
precision.
EXAMPLES:
sage: (2/3).n()
0.666666666666667
sage: a = 2/3
sage: pi.n(digits=10)
3.141592654
sage: pi.n(prec=20) # 20 bits
3.1416
Class Docstring:
<attribute '__doc__' of 'builtin_function_or_method' objects>
To create elements in higher precision rings you should use something
like the following and not what I gave as an example earlier:
sage: CC200=ComplexField(200)
sage: b=CC200(1/3,1/7)
sage: b
0.33333333333333333333333333333333333333333333333333333333333 +
0.14285714285714285714285714285714285714285714285714285714286*I
Cheers,
Michael
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---