# [Maxima] ev-bug

Oliver Kullmann O.Kullmann at swansea.ac.uk
Thu May 14 12:57:47 CDT 2009

```On Thu, May 14, 2009 at 11:26:09AM -0600, Robert Dodier wrote:
> On Thu, May 14, 2009 at 11:04 AM, Oliver Kullmann
> <O.Kullmann at swansea.ac.uk> wrote:
>
> > Likely the weakness is the quadratic effort for evaluating the L[i] !
>
> Well, bear in mind that Maxima carries out arithmetic via simplification.
> That makes symbolic results possible, but at the price of making arithmetic
> on literal numbers more complicated than it has to be. So if some formulation
> of the problem runs faster than another, I would be interested to know how
> simplification plays into it. In the absence of evidence to the contrary,
> I would guess indexing is a secondary problem.
>
> To some extent, Maxima can detect special cases when translating a
> function to Lisp code. When all operands are known to be numbers, that
> could yield a substantial speed-up.
>

The order of time spent fits quite well:

(%i10) block([L:create_list(i,i,1,100000)], for i from 1 thru 100000 do L[i]);
Evaluation took 133.1410 seconds (264.5500 elapsed)
(%o10) done
(%i11) block([L:create_list(i,i,1,100000)], create_list(L[i],i,1,100000))\$
Evaluation took 112.6750 seconds (223.7930 elapsed)
(%i12) block([L:create_list(i,i,1,100000)], for x in L do x)\$
Evaluation took 0.3200 seconds (0.3190 elapsed)

Those 110s just for creating the list [L[1], ..., L[100000]] seem to be the difference
between "bob" and "rcs" before.

Indexing in lists is a bloody disaster, and I realised huge speed-ups just
be eliminated them.

Oliver

> FWIW
>
> Robert Dodier

--
Dr. Oliver Kullmann
Computer Science Department
Swansea University