Re: [Axiom-mail] A slow summation

2007-06-13 Thread Bill Page
On 6/13/07, Alasdair McAndrew wrote: Wondering about nice little numeric exercises to help introduce Axiom to a small group of students, I attempted to sum the first 2 reciprocals: reduce(+,[1.0/i for i in 1..2]) This works, but is (I think) unreasonably slow; it takes over 21 seconds

Re: [Axiom-mail] A slow summation

2007-06-13 Thread Bill Page
On 6/13/07, Bill Page [EMAIL PROTECTED] wrote: It turns out that Axiom's list data type is very slow and almost all the time is spent building the list. You can avoid this by preallocating an arrary of sufficient size. E.g. (2) - for i in 1..2 repeat rlist(i-1):=1.0/i

Re: [Axiom-mail] A slow summation

2007-06-13 Thread Bill Page
Of course these also make some sense :-) (1) - sum(1/x,x=1.0..2.0) (1) 10.4807282172 29327571 Type: Union(Expression Float,...) Time: 0.02 (IN) + 3.10 (EV) + 0.02 (OT) + 0.32 (GC) = 3.45 sec (2) - sum(1/x,x=(1.0..2.0)$Segment DoubleFloat) (2)