makelist(): argument size appears restricted to integer -- RFC
Subject: makelist(): argument size appears restricted to integer -- RFC
From: Barton Willis
Date: Tue, 21 Apr 2009 09:37:49 -0500
The user documentation doesn't mention it, but the difference between the
third and fourth
arguments to makelist must be a Common Lisp fixnum. The CL standard
doesn't specify the size
in bits of a fixnum. On one compiler I tried, 2^28 is a fixnum, but 2^29
isn't. Since
30! > 2^107 >>> 2^28, there is no possibility of using makelist to build
a list of
30! integers.
The restriction to a CL fixnum is reasonable. A list of a few million
(2^20)
integers is about all that Maxima can handle--lists of expressions cannot
exceed about
10^5 or so items.
If all you want to do is sum(k^2,k,1,30!), Maxima has no problem with
that:
(%i3) sum(k^2,k,1,n), simpsum;
(%o3) (2*n^3+3*n^2+n)/6
(%i4) subst(n=30!,%);
(%o4)
6220982362625999092956982917190059580036449791652138192382722560208520946113558464972718080000000
(%i5) bfloat(%);
(%o5) 6.220982362625999b96
Barton
maxima-bounces at math.utexas.edu wrote on 04/21/2009 06:06:38 AM:
> [image removed]
>
> [Maxima] makelist(): argument size appears restricted to integer -- RFC
>
> Robyn Dawn Hannigan
>
> to:
>
> Maxima mailing list
>
> 04/21/2009 07:10 AM
>
> Sent by:
>
> maxima-bounces at math.utexas.edu
>
> Hello List,
>
> In the last few days i have been experimenting with list programming. i
> came across the following (IMO) defficiency in makelist.
>
> >From the manual:
>
--------------------------------------------------------------------------
> Constructs and returns a list, each element of which is generated from
> expr.
> makelist (expr, i, i_0, i_1) returns a list, the j'th element of which
> is equal to ev (expr, i=j) for j equal to i_0 through i_1.
> makelist (expr, x, list) returns a list, the j'th element of which is
> equal to ev (expr, x=list[j]) for j equal to 1 through length (list).
>
-----------------------------------------------------------------------------
>
> This is all well and good.
> The following error was observed ion a wxMaxima session.
>
> (%i1) s(n):= block([n:n],
> apply("+",map(lambda([x],x^2),makelist(x,x,1,n))))$
> (%i2) s(30!);
> If 4 arguments are given to MAKELIST, the difference of the 3rd and 4th
> arguments should evaluate to a non-negative integer:
> 265252859812191058636308479999999
> #0: s(n=265252859812191058636308480000000)
> -- an error. To debug this try debugmode(true);
>
>
>
> What i assume this means is that the bug can be reduced to
>
> makelist(x,x,1,265252859812191058636308479999999)
>
> Which does indeed produce the same error message on my equipment:
> wxMaxima 0.8.1 http://wxmaxima.sourceforge.net
> Maxima 5.17.1 http://maxima.sourceforge.net
> Using Lisp SBCL 1.0.27-r10-gentoo
>
> Can anyone help me understand where it came from please?
> Many Thanks,
> Robyn
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima