On Dec 2, 2008, at 6:04 PM, ggrafendorfer wrote:

>> 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
>>
>
> this does not look nice to me:
>
> sage: CDF(i*i) == CDF(i^2)
> False
>
> I mean, this is OK (to be expected):
>
> sage: CDF(i*i) == CDF(i^2.)
> False

The difference being the dot after the two? Note that

sage: sqrt(2.0) * sqrt(2.0) == 2.0
False

That's the price one pays when doing numerical computations.

> Again, if I want performance I could use i^2.,

Um... that's *slower*, right?

> things like this
> (coercing to RDF or CDF) one anyway has to do frequently in sage to
> increase performance


It depends on the kind of computations you're doing. This is pretty  
fast too

sage: K.<i> = QuadraticField(-1)
sage: timeit("i*i")
625 loops, best of 3: 1.94 µs per loop
sage: (i+19)^100
sage: (i+17)^100
-52244955556442742077981550113261718720954576617841829250599535493109374 
5411367001259183340635741576808733291492457595273216*i +  
120997782942344599394513433198489903651843648304833395860879396174267844 
5437008904989813965395157987726428106757657159794688
sage: timeit("(i+17)^100")
625 loops, best of 3: 70.5 µs per loop

- 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