[sage-devel] Fwd: Numerics in SAGE

2007-07-26 Thread William Stein
Hi, This may be of general interest to sage-devel people who are interested in SAGE becoming a "viable alternative to MATLAB". -- William -- Forwarded message -- From: Randy LeVeque (Applied Math at UW) Date: Jul 26, 2007 2:12 PM Subject: Numerics in SAGE To: Hans Petter Langta

[sage-devel] Re: accessing GAP's small groups database from the notebook

2007-07-26 Thread Dan Christensen
"William Stein" <[EMAIL PROTECTED]> writes: > Very interesting. When you install the gap database, SAGE runs > gap_reset_workspace() to update the cached workspace on the machine > on which the database is installed. Because a single home directory could > be used by multiple machines, there ar

[sage-devel] Re: accessing GAP's small groups database from the notebook

2007-07-26 Thread William Stein
On 7/26/07, Dan Christensen <[EMAIL PROTECTED]> wrote: > > "David Joyner" <[EMAIL PROTECTED]> writes: > > > Could you please try gap_reset_workspace() and then restart SAGE > > and see if the examples start? > > That fixed it! Thanks. Not sure what I did. The problem occurred on > two different

[sage-devel] Re: accessing GAP's small groups database from the notebook

2007-07-26 Thread Dan Christensen
"David Joyner" <[EMAIL PROTECTED]> writes: > Could you please try gap_reset_workspace() and then restart SAGE > and see if the examples start? That fixed it! Thanks. Not sure what I did. The problem occurred on two different systems, which my home directory is mirrored between. If it happens

[sage-devel] Re: interaction between GAP and notebook

2007-07-26 Thread William Stein
On 7/26/07, Dan Christensen <[EMAIL PROTECTED]> wrote: > Some other minor issues about using GAP within the notebook, under > 2.7.1. I've put my entire worksheet in GAP mode using the menu at > the top. The following things don't work correctly: > > 0) If I type something that gives an error in

[sage-devel] Re: accessing GAP's small groups database from the notebook

2007-07-26 Thread David Joyner
None of these problems arise on an intel macbook running sage 2.7. I also tested it using gap_console() and the example worked in that mode too. Could you please try gap_reset_workspace() and then restart SAGE and see if the examples start? +++ On 7/26/07, Dan Ch

[sage-devel] interaction between GAP and notebook

2007-07-26 Thread Dan Christensen
Some other minor issues about using GAP within the notebook, under 2.7.1. I've put my entire worksheet in GAP mode using the menu at the top. The following things don't work correctly: 0) If I type something that gives an error in GAP, the error message is buried in a python exception/backtrace

[sage-devel] accessing GAP's small groups database from the notebook

2007-07-26 Thread Dan Christensen
I'm having trouble accessing GAP's small groups database from the notebook. I'm using the binary install of 2.7.1 on 32-bit Debian. I have installed database_gap-4.4.9 and gap_packages-4.4.9_2. If I do "sage -gap", then inside the gap process, I can do: gap> NumberSmallGroups(2^3); 5 But if I

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Bill Hart
Alternatively you could just use the implementation here: http://www.ark.in-berlin.de/part.c which seems to only rely on mpfr and GMP. However, since the Pari version was based on it, I suspect it may also need correction. He does seem to adjust the precision as he goes, but I've no idea how fa

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Bill Hart
Here we go. Apparently g(h,q) = q*s(h,q) where s(h,q) is a dedekind sum. Then for h < q if r_0, r_1, ..., r_{n+1} are the remainders occurring in the Euclidean algorithm when computing gcd(h,q) (of which there should be about log q) then: s(h,q) = 1/12 * sum_{i=1}^{n+1}((-1)^(i+1) (r_i^2 + r_{i-

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Bill Hart
OK, apparently the Dedekind sums should be done using an algorithm due to Apostol. I haven't tracked it down yet, but this is clearly what we need. Bill. On 26 Jul, 23:37, Bill Hart <[EMAIL PROTECTED]> wrote: > On 26 Jul, 23:18, Jonathan Bober <[EMAIL PROTECTED]> wrote: > > > s(h,k) = h(k - 1)(2

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Bill Hart
On 26 Jul, 23:18, Jonathan Bober <[EMAIL PROTECTED]> wrote: > s(h,k) = h(k - 1)(2k - 1)/(6k) - (k-1)/4 - > (1/k) sum_{j=1}^{k-1} j*floor(hj/k). > > (To compute the floor in the inner sum, you can just use integer > division.) Yes, this will be faster. Of course integer

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Jonathan Bober
On Thu, 2007-07-26 at 13:10 -0700, Bill Hart wrote: > > Perhaps if one had a fast way of evaluating the Dedekind sum, one > might have a chance. > > Bill. > I think this gives a faster way to compute it: Write the sum as s(h,k) = sum_{j=1}^{k-1} j/k [hj/k - floor(hj/k) - 1/2] (This isn't s

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Bill Hart
There are two tricks I can see that are required to make this faster. Firstly notice that L(n,q)*Psi(n,q) is relatively small once q gets beyond a certain point. Thus L(n,q)*Psi(n,q) can be computed using ordinary double precision for q greater than some very small limit (depending on n). If one

[sage-devel] Re: GAP and rings?

2007-07-26 Thread Dan Christensen
"David Joyner" <[EMAIL PROTECTED]> writes: > You probably know this already but the 2003 survey > www.math.rwth-aachen.de/~Gerhard.Hiss/Preprints/AlgoRepTheo.pdf > discusses briefly what is/was out there. I don't think it mentions > recent packages such as laguna, crime, and hap, but I don't know

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Bill Hart
Pari implements it, but incorrectly: sage: number_of_partitions(5*10535+4,algorithm="pari") 132775694853416614410709359082850304628573507097 148711672236023178345995078715426574030466347126 367130008280402558755564770977624160764152691390 102001213796297899514590335375857238756973648770 246446295

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Mike Hansen
I just found this on http://reference.wolfram.com/mathematica/note/SomeNotesOnInternalImplementation.html: "PartitionsP[n] uses Euler's pentagonal formula for small n, and the non-recursive Hardy-Ramanujan-Rademacher method for larger n." --Mike On 7/26/07, Alec Mihailovs <[EMAIL PROTECTED]> wr

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Nick Alexander
"William Stein" <[EMAIL PROTECTED]> writes: > QUESTIONS: Why is Mathematica about 10 times faster than PARI > at this? What are the best ways to compute the number > of partitions of n? Is it a calculation involving fast arithmetic > with dense polynomials of large degree, which would be best

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Alec Mihailovs
From: "Mike Hansen" <[EMAIL PROTECTED]> > I'm not sure where the bottleneck in PARI is since I can't imagine > Mathematica uses a different method to compute the number of > partitions. I don't know what is used in the latest Mathematica version, but originally NumberOfPartitions function in th

[sage-devel] Re: computing the number of partitions of an integer

2007-07-26 Thread Mike Hansen
The fastest way I know of to compute the number of integer partitions is to use the Hardy-Ramanujan-Rademacher formula ( see Rademacher series on http://en.wikipedia.org/wiki/Integer_partition ), and I'm pretty sure this is what PARI uses. From modules/part.c: * This program is basically the i