On Dec 2, 2008, at 5:40 PM, ggrafendorfer wrote:

>
> Hi Michael,
>
>> You are using CDF == Complex Double Field, so numerical noise is  
>> to be
>> expected. IEEE arithmetic might be fast, but you pay for that speed
>> with imprecise results. It might be possible to compile without
>> optimization and get a "correct" result in that case, but that could
>> change by using another gcc release.
>
> OK, but if you write it this way it may be clearer what I mean:
>
> sage: i^2
> -1
> sage: CDF(_)
> -1.0 + 1.22460635382e-16*I
>
> namely that the result of i^2 should be exact,

Perhaps we should special case for (small) integer powers, but that  
would slow other stuff down. What's happening here is that the  
symbolic expression "i^2" is getting turned into CDF(i)^CDF(2).  
Simplification happens on printing, not on construction.

sage: CDF(simplify(i^2))
-1.0

> if I want performance I could write i^2.


CDF is the one with performance, by two orders of magnitude.

sage: timeit("i*i")
625 loops, best of 3: 46.9 µs per loop
sage: CDFi = CDF(i)
sage: timeit("CDFi * CDFi")
625 loops, best of 3: 357 ns per loop

sage: timeit("imag(1/(i+1))")
5 loops, best of 3: 22.5 ms per loop
sage: timeit("imag(1/(CDFi+1))")
625 loops, best of 3: 4.36 µs per loop

- Robert
--~--~---------~--~----~------------~-------~--~----~
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-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to