After an upgrade from alpha0 on Fedora 9, 32 bit one failure:
[jaap@paix sage-3.4.2.alpha0]$ ./sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
**********************************************************************
File "/home/jaap/downloads/sage-3.4.2.alpha0/devel/sage/sage/matrix/matrix_symbolic_dense.pyx", line 413:
sage: M.determinant()
Expected:
4*x - 6
Got:
determinant(sage513)
**********************************************************************
1 items had failures:
1 of 9 in __main__.example_18
***Test Failed*** 1 failures.
For whitespace errors, see the file /home/jaap/downloads/sage-3.4.2.alpha0/tmp/.doctest_matrix_symbolic_dense.py
[83.9 s]
exit code: 1024
Now doing a fresh install on this machine.
Still waiting for a fresh install (and test) on Fedora 10, 32 bits.
Jaap
>
> Still waiting for a fresh install (and test) on Fedora 10, 32 bits.
>
As a follow up: Fedora 10, 32 bits, fresh install:
./sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
*** *** Error: TIMED OUT! PROCESS KILLED! *** ***
*** *** Error: TIMED OUT! *** ***
*** *** Error: TIMED OUT! *** ***
[360.2 s]
exit code: 1024
----------------------------------------------------------------------
The following tests failed:
sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
Total time for all tests: 360.3 seconds
In a retry:
[jaap@peace sage-3.4.2.rc0]$ ./sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
**********************************************************************
File "/home/jaap/Download/sage-3.4.2.rc0/devel/sage/sage/matrix/matrix_symbolic_dense.pyx", line 214:
sage: -matrix(SR, 2, range(4))
Exception raised:
Traceback (most recent call last):
File "/home/jaap/Download/sage-3.4.2.rc0/local/bin/ncadoctest.py", line 1231, in run_one_test
self.run_one_example(test, example, filename, compileflags)
File "/home/jaap/Download/sage-3.4.2.rc0/local/bin/sagedoctest.py", line 38, in run_one_example
OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
File "/home/jaap/Download/sage-3.4.2.rc0/local/bin/ncadoctest.py", line 1172, in run_one_example
compileflags, 1) in test.globs
File "<doctest __main__.example_11[2]>", line 1, in <module>
-matrix(SR, Integer(2), range(Integer(4)))###line 214:
sage: -matrix(SR, 2, range(4))
File "matrix0.pyx", line 1497, in sage.matrix.matrix0.Matrix.__repr__ (sage/matrix/matrix0.c:7963)
File "matrix0.pyx", line 1526, in sage.matrix.matrix0.Matrix.str (sage/matrix/matrix0.c:8252)
File "matrix0.pyx", line 172, in sage.matrix.matrix0.Matrix.list (sage/matrix/matrix0.c:2839)
File "matrix_symbolic_dense.pyx", line 349, in sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense._list (sage/matrix/matrix_symbolic_dense.c:4257)
File "matrix_symbolic_dense.pyx", line 123, in sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense.get_unsafe (sage/matrix/matrix_symbolic_dense.c:3011)
File "/home/jaap/Download/sage-3.4.2.rc0/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 10261, in symbolic_expression_from_maxima_string
raise TypeError, "unable to make sense of Maxima expression '%s' in Sage"%s
TypeError: unable to make sense of Maxima expression '(-sage196)[1,1]' in Sage
**********************************************************************
File "/home/jaap/Download/sage-3.4.2.rc0/devel/sage/sage/matrix/matrix_symbolic_dense.pyx", line 413:
sage: M.determinant()
Expected:
4*x - 6
Got:
determinant(sage513)
**********************************************************************
2 items had failures:
1 of 3 in __main__.example_11
1 of 9 in __main__.example_18
***Test Failed*** 2 failures.
For whitespace errors, see the file /home/jaap/Download/sage-3.4.2.rc0/tmp/.doctest_matrix_symbolic_dense.py
[89.0 s]
exit code: 1024
----------------------------------------------------------------------
The following tests failed:
sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
Total time for all tests: 89.0 seconds
[jaap@peace sage-3.4.2.rc0]$
Jaap
Best,
Alex
On Apr 30, 2009, at 05:23 , mabshoff wrote:
>
> Hello folks,
>
> here goes 3.4.2.rc0 - a little later than planned, but it seems like
> we fixed all the issues (and more) that needed to be fixed. We finally
> merged the symbolic logic code written well over *18* months ago, but
> "no doctests, no merge" is something we take seriously. On top of that
> we are at
>
> Overall weighted coverage score: 71.1%
> Total number of functions: 22348
> We need 881 more function to get to 75% coverage.
> We need 1999 more function to get to 80% coverage.
> We need 3116 more function to get to 85% coverage.
>
> Note that this is also due to splitting DSage into its own spkg. We
> will discuss what to do with the DSage codebase at SD15 I assume.
>
> The source tarball, upgrade bits as well as a sage.math binary are in
> the usual place at
>
> http://sage.math.washington.edu/home/mabshoff/release-cycles-3.4.2/
My first attempt to build this (Mac OS X, 10.5.6, Dual Quad Xeon) blew
up with python-2.5. I had two of these errors:
Compiling /Users/tmp/sage-3.4.2.rc0/local/lib/python2.5/test/
test_multibytecodec.py ...
Sorry: UnicodeError: ("\\N escapes not supported (can't load
unicodedata module)",)
(i.e., twice with the same file), and the final straw was:
Sleeping for three seconds before testing python
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/sage-3.4.1/local/lib/python2.5/md5.py", line 6, in
<module>
from hashlib import md5
File "/tmp/sage-3.4.1/local/lib/python2.5/hashlib.py", line
133, in <module>
md5 = __get_builtin_constructor('md5')
File "/tmp/sage-3.4.1/local/lib/python2.5/hashlib.py", line 60,
in __get_builtin_constructor
import _md5
ImportError: No module named _md5
md5 module failed to import
I restarted the build without changing anything, and it completed w/o
complaints.
The log file is at
sage.math.washington.edu:~justin/logs/3.4.2.rc0.log
if you want to paw through it looking for hints; I didn't see anything
obvious, but your younger eyes are probably sharper than mine :-}
Justin
--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
--
Democracy is two wolves and a lamb
voting on what to have for lunch.
Liberty is a well-armed lamb contesting
the vote.
Yes, it is easily to DOS the notebook if one tries, but I'm wary of a
big button that "accidently" does so. Taring up the directories for a
dozen worksheets can take several minutes.
I'll try to get a patch out tonight, perhaps as a first pass it would
be good to use to the opposite of the accounts option in the notebook
() command.
- Robert
>
> Now doing a fresh install on this machine.
>
On this fresh install first success, followed by the failure:
SAGE build/upgrade complete!
[jaap@paix sage-3.4.2.rc0]$ ./sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
[125.6 s]
----------------------------------------------------------------------
All tests passed!
Total time for all tests: 125.8 seconds
[jaap@paix sage-3.4.2.rc0]$ ./sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
**********************************************************************
File "/home/jaap/downloads/sage-3.4.2.rc0/devel/sage/sage/matrix/matrix_symbolic_dense.pyx", line 413:
sage: M.determinant()
Expected:
4*x - 6
Got:
determinant(sage513)
**********************************************************************
1 items had failures:
1 of 9 in __main__.example_18
***Test Failed*** 1 failures.
For whitespace errors, see the file /home/jaap/downloads/sage-3.4.2.rc0/tmp/.doctest_matrix_symbolic_dense.py
[74.1 s]
exit code: 1024
----------------------------------------------------------------------
The following tests failed:
sage -t "devel/sage/sage/matrix/matrix_symbolic_dense.pyx"
Total time for all tests: 74.1 seconds
[jaap@paix sage-3.4.2.rc0]$
Weird!
Jaap
In the future of python, things that don't have a sensible order throw a
TypeError when comparing:
http://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
Why don't we just throw an error?
Jason
--
Jason Grout
>> In the future of python, things that don't have a sensible order
>> throw a TypeError when comparing:
>> http://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
>> Why don't we just throw an error?
>
> As for throwing an error, probably that should be done Sage-wide for
> things that don't make sense, not piecemeal. At least I don't feel
> comfortable opening that can of worms!
Yep, this was opened a while back, and it turned into one of the
longest treads ever... I would still like to see conclusion on that.
- Robert
Despite being a huge thread, the resolution is really easy. I think
we should do the following: "The ordering comparison operators (<, <=,
>=, >) should raise a TypeError exception when the operands don’t have
a meaningful natural ordering. Thus, expressions like 1 < '', 0 > None
or len <= len will no longer be valid. A corollary is that sorting a
heterogeneous list no longer makes sense – all the elements must be
comparable to each other. Note that this does not apply to the == and
!= operators: objects of different incomparable types will always
compare unequal to each other."
The question is now how to do this. Little by little, or all at once.
I prefer little by little whenever possible, so is that possible
here?
-- William
+1
What's not resolved is how much the system should try to be clever
when comparing, e.g., and element of QQ[sqrt(2)] and of QQ[sqrt(3)].
> The question is now how to do this. Little by little, or all at
> once. I prefer little by little whenever possible, so is that
> possible here?
If this can help measure the progress, I can add a systematic test in
the Sets() category, so that for P a parent, P.check() will check that
P.an_element() < None actually raises an error.
Cheers,
Nicolas
--
Nicolas M. Thiéry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/
There was a lot of other stuff in that thread, but yes, lets do this.
> What's not resolved is how much the system should try to be clever
> when comparing, e.g., and element of QQ[sqrt(2)] and of QQ[sqrt(3)].
If a + b works, than a < b should be compared in parent(a+b) (which
may or may not have an ordering). For the moment, the above would
fail. (In fact, QQ[sqrt(a)] doesn't yet come with an embedding...)
Another unresolved issue was how to handle RealField(53).pi() ==
RealField(500).pi()
- Robert
>
> Hi, Michael,
>
> On Apr 30, 2009, at 05:23 , mabshoff wrote:
>
>>
>> Hello folks,
>>
>> here goes 3.4.2.rc0 - a little later than planned, but it seems like
>> we fixed all the issues (and more) that needed to be fixed. We
>> finally
>> merged the symbolic logic code written well over *18* months ago, but
>> "no doctests, no merge" is something we take seriously. On top of
>> that
>> we are at
>>
>> Overall weighted coverage score: 71.1%
>> Total number of functions: 22348
>> We need 881 more function to get to 75% coverage.
>> We need 1999 more function to get to 80% coverage.
>> We need 3116 more function to get to 85% coverage.
>>
>> Note that this is also due to splitting DSage into its own spkg. We
>> will discuss what to do with the DSage codebase at SD15 I assume.
>>
>> The source tarball, upgrade bits as well as a sage.math binary are in
>> the usual place at
>>
>> http://sage.math.washington.edu/home/mabshoff/release-cycles-3.4.2/
>
> My first attempt to build this (Mac OS X, 10.5.6, Dual Quad Xeon) blew
> up with python-2.5. I had two of these errors:
[snip]
> I restarted the build without changing anything, and it completed w/o
> complaints.
"make test" for the second attempt would not work because of seg-
faults very early in the run.
I then rebuilt (3rd time) and retested 3.4.2.rc0 in the above
configuration. This time, it built w/o errors. Testing showed only
one problem, a failure in the dsage test which I've seen before:
=
=
=
=
=
=
=
========================================================================
[ERROR]:
sage.dsage.twisted.tests.test_remote.ClientRemoteCallsTest.testremoteSu
bmitBadJob
Traceback (most recent call last):
Failure: twisted.trial.util.DirtyReactorAggregateError: Reactor was
unclean.
Selectables:
<Broker #0 on 60222>
=
=
=
=
=
=
=
========================================================================
[ERROR]:
sage
.dsage
.twisted.tests.test_remote.WorkerRemoteCallsTest.testremote_job_failed
I reran sage-dsage-trial by hand and it passed.
Justin
--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Absorption of Federal Funds
--------
If you're not confused,
You're not paying attention
--------
Brownies are overrated.
I played around with prime_pi() for a while, both on sage.math and on
my laptop at the office (macbook running 32-bit archlinux). I didn't
manage to get a segfault on either machine with prime_pi(2^50). I
guess that's the good news? Anyway, the bad news is that the answers
returned do not agree between the two machines, e.g.
{{{
# on sage.math
sage: time prime_pi(2^50)
CPU times: user 4854.46 s, sys: 3.17 s, total: 4857.63 s
Wall time: 4857.73 s
33483379603407
#
# on my laptop
sage: time prime_pi(2^50)
CPU times: user 5555.60 s, sys: 7.81 s, total: 5563.40 s
Wall time: 5598.64 s
21969300962685
}}}
I'm pretty sure that the sage.math answer is more likely to be the
right one. You can maybe guess from the timings why I didn't try
prime_pi(2^51). I have, however, tried smaller values. I'm going to
put that data up on the trac ticket.
I have absolutely no idea what's wrong, but something definitely is,
and hopefully this will help someone fix it.
Best,
Alex
Mathematica 6 (on a Sun SPARC) gives an answer in far less time than Sage:
In[3]:= PrimePi[2^50]
PrimePi::largp:
Argument 1125899906842624 in PrimePi[1125899906842624]
is too large for this implementation.
Out[3]= PrimePi[1125899906842624]
Well, perhaps not really an answer!
You should have used Mathematica - it returns its answer very quickly:
Mathematica 6.0 for Sun Solaris SPARC (64-bit)
Copyright 1988-2008 Wolfram Research, Inc.
In[1]:= ?PrimePi
PrimePi[x] gives the number of primes \[Pi] (x) less than or equal to x.
In[2]:= PrimePi[2^50]
PrimePi::largp:
Argument 1125899906842624 in PrimePi[1125899906842624]
is too large for this implementation.
Out[2]= PrimePi[1125899906842624]
Andrew looked into this whole issue a while ago, and told me that the
prime_pi he implemented *should* only work up to about 2^40, and the
algorithm would take far too long above there. I thought he had
included an error message if the input exceeds 2^40, but I guess not.
So +1 to your suggestion above, but with a smaller bound that 2^48.
He told me Mathematica can go up to about 2^45 or so, but not beyond.
The algorithm in Mathematica is completely different (and better) than
what Andrew implemented for Sage. As far as I know the situation for
computing pi(X) using general purpose math software is thus:
* Mathematica -- has the best implementation available
* Sage -- now has the second best implementation available
* Pari, Maple, Matlab -- "stupid" implementations, which all simply
enumerate all primes up to x and see how many there are. Useless, and
can't come close to what Sage or Mathematica do.
-- William
Hi Micheal,
Yes, I can figure it out.
The upper limit is PrimePi[249999999999999] (2.5x10^14), which
Mathematica gives as 7783516108362. It took 20 minutes or so on a
heavily loaded machine.
In[95]:= PrimePi[249999999999999]
Out[95]= 7783516108362
It can not manage PrimePi[250000000000000]
2^47 is 1.41x10^14,
2^48 is 2.81x10^14.
Since the maximum that can be handled is just under 2.5x10^14,
Mathematica can compute PrimePi[2^47], but not PrimePi[2^48]
Here's a table of PrimePi[2^n], with n ranging from 0 to 47. It took
roughly 20 minutes or so to compute the table.
In[19]:= Table[{n,PrimePi[2^n]},{n,0,47}]
Out[19]= {{0, 0}, {1, 1}, {2, 2}, {3, 4}, {4, 6}, {5, 11}, {6, 18}, {7, 31},
> {8, 54}, {9, 97}, {10, 172}, {11, 309}, {12, 564}, {13, 1028},
> {14, 1900}, {15, 3512}, {16, 6542}, {17, 12251}, {18, 23000},
> {19, 43390}, {20, 82025}, {21, 155611}, {22, 295947}, {23, 564163},
> {24, 1077871}, {25, 2063689}, {26, 3957809}, {27, 7603553},
> {28, 14630843}, {29, 28192750}, {30, 54400028}, {31, 105097565},
> {32, 203280221}, {33, 393615806}, {34, 762939111}, {35, 1480206279},
> {36, 2874398515}, {37, 5586502348}, {38, 10866266172},
> {39, 21151907950}, {40, 41203088796}, {41, 80316571436},
> {42, 156661034233}, {43, 305761713237}, {44, 597116381732},
> {45, 1166746786182}, {46, 2280998753949}, {47, 4461632979717}}
PS, Mathematica computes PrimePi[some_negative_number] as 0. Does Sage
handle that case ok?
Dave
>> He told me Mathematica can go up to about 2^45 or so, but not beyond.
>
> At least for MMA 6.0 on linux x86-64 the limit seems to be around
> 2^47:
As I said in the other post, the limit is PrimePi[249999999999999].
> MMA Sage
>
> 2^44: 18.04 110.88 (597116381732)
> 2^45: 29.98 207.61 (1166746786182)
> 2^46: 47.59 389.98 (2280998753949)
> 2^47: 89.25 728.84 (4461632979717)
> 2^48: NA :) about an hour - correct?
>
> According to Alex's numbers at least on his laptop 2^46 was correct on
> 32 bits, but given the length of the test (~6 minutes on sage.math
> this isn't really doctestable).
>
>> The algorithm in Mathematica is completely different (and better) than
>> what Andrew implemented for Sage. As far as I know the situation for
>> computing pi(X) using general purpose math software is thus:
One (admitidly unlikely) possibility is that Wolfram have used the same
algorithm, but used assembly code. I think they claim the kernel is
C/C++, but that permits bits of inline assembly.
>> * Mathematica -- has the best implementation available
>>
>> * Sage -- now has the second best implementation available
>
> Yep, the old implementation was about 1000 times slower than Andrew's
> which is about 5 times slower than MMA 6.0 - so great job from
> catching us up from 5000 times to only 5 times :).
I gather you have managed to get a SPARC version of Sage running. It
would be interesting to compare the performance on SPARC of Mathematica
and Sage. I very much doubt Wolfram would have used hand-optimised
assembly code on SPARC, so if the timings still show Mathematica to be
5x quicker, then yes, I would agree it's a better algorithm. But if the
timings are very similar, it suggests to me that perhaps the better
performance of Mathematica is due to writing assembly code, rather than
using a high-level language.
>> * Pari, Maple, Matlab -- "stupid" implementations, which all simply
>> enumerate all primes up to x and see how many there are. Useless, and
>> can't come close to what Sage or Mathematica do.
> Well, what should we pick as upper bound? 2^40 seems to be what Andrew
> suggests, but maybe 2^42 or 2^43? In that range we can actually add
> #long doctests and I would be much more comfortable that we would at
> least catch potential issues.
Personally, if Sage can go to 249999999999999, then I would use that as
an upper bound. If the algorithm in Sage gives the same answer as
Mathematica
In[95]:= PrimePi[249999999999999]
Out[95]= 7783516108362
then why not use Sage to there? The poor SPARC I used for this was very
heavily loaded and quite old, but it only took 20 minutes or so. Even an
algorithm that is 5x slower should be able to compute
primepi(249999999999999) in under an hour on any half-decent modern
machine.
Of course, a search of the literature for a better algorithm might have
some millage. Unfortunately, I no longer have access to a university
account and so can't search journals without paying for access to
individual ones, which clearly I can't justify. Neither am I
particularly good at maths, having never maths studied beyond that
needed for an engineering degree
One unfortunate side-effect of the closed-source vs open-source code is
the fact that if open-source code (e.g. Sage) has a faster algorithm
than Mathematica, then it's relatively easy for WRI to look at the
algorithm in Sage and use the same one, to bring Mathematica and Sage to
similar performances. The converse is not true of course - it is not
possibly for Sage developers to find out the algorithm Mathematica uses.
However, a look at
http://mathworld.wolfram.com/PrimeCountingFunction.html
might give some clues as to the algorithm Mathematica uses. Although the
algorithm Mathematica is not stated in that Mathworld page, there are a
number of references. Two look interesting:
Mapes, D. C. "Fast Method for Computing the Number of Primes Less than a
Given Limit." Math. Comput. 17, 179-185, 1963.
Gourdon, X. "New Record Computation for pi(x), x=10^21." 27 Oct 2000.
http://listserv.nodak.edu/scripts/wa.exe?A2=ind0010&L=nmbrthry&P=2988
The link
http://listserv.nodak.edu/cgi-bin/wa.exe?A2=ind0010&L=nmbrthry&P=2988
states the algorithm used, but in a way I don't understand. It says:
"This value has been checked by computing pi(10^21+10^8) with
a different parameter y used in the algorithm"
but y is not defined!
This page:
http://reference.wolfram.com/mathematica/note/SomeNotesOnInternalImplementation.html#12788
says what algorithm is used in Mathematica to compute PrimePi, and it
is definitely *not* the one used in Sage. It is a completely
different harder-to-implement algorithm with better asymptotic
complexity.
In any case, we definitely do intend to install Mathematica on our new
Sparc T5240 box, since UW has a site license for Mathematica which
includes a Sparc Solaris version.
-- William
>> He told me Mathematica can go up to about 2^45 or so, but not beyond.
>
> At least for MMA 6.0 on linux x86-64 the limit seems to be around
> 2^47:
As I said in the other post, the limit is PrimePi[249999999999999].
> MMA Sage
>
> 2^44: 18.04 110.88 (597116381732)
> 2^45: 29.98 207.61 (1166746786182)
> 2^46: 47.59 389.98 (2280998753949)
> 2^47: 89.25 728.84 (4461632979717)
> 2^48: NA :) about an hour - correct?
>
> According to Alex's numbers at least on his laptop 2^46 was correct on
> 32 bits, but given the length of the test (~6 minutes on sage.math
> this isn't really doctestable).
>
>> The algorithm in Mathematica is completely different (and better) than
>> what Andrew implemented for Sage. As far as I know the situation for
>> computing pi(X) using general purpose math software is thus:
One (admitidly unlikely) possibility is that Wolfram have used the same
algorithm, but used hand-optimised assembly code, rather than a
high-level language I think WRI claim the kernel is C/C++, but that
permits bits of inline assembly.
>> * Mathematica -- has the best implementation available
>>
>> * Sage -- now has the second best implementation available
>
> Yep, the old implementation was about 1000 times slower than Andrew's
> which is about 5 times slower than MMA 6.0 - so great job from
> catching us up from 5000 times to only 5 times :).
I gather you have managed to get a SPARC version of Sage running. It
would be interesting to compare the performance on SPARC of Mathematica
and Sage. I very much doubt Wolfram would have used hand-optimised
assembly code on SPARC, so if the timings still show Mathematica to be
5x quicker, then yes, I would agree it's a better algorithm. But if the
timings are very similar, it suggests to me that perhaps the better
performance of Mathematica is due to writing assembly code, rather than
using a high-level language.
>> * Pari, Maple, Matlab -- "stupid" implementations, which all simply
>> enumerate all primes up to x and see how many there are. Useless, and
>> can't come close to what Sage or Mathematica do.
> Well, what should we pick as upper bound? 2^40 seems to be what Andrew
> suggests, but maybe 2^42 or 2^43? In that range we can actually add
> #long doctests and I would be much more comfortable that we would at
> least catch potential issues.
Personally, if Sage can go to 249999999999999, then I would use that as
an upper bound. If the algorithm in Sage gives the same answer as
Mathematica
In[95]:= PrimePi[249999999999999]
Out[95]= 7783516108362
then why not use Sage to there? The poor SPARC I used for this was very
heavily loaded and quite old, but it only took 20 minutes or so. Even an
algorithm that is 5x slower should be able to compute
primepi(249999999999999) in under an hour on any half-decent modern
machine.
Of course, a search of the literature for a better algorithm might have
some millage. Unfortunately, I no longer have access to a university
account and so can't search journals without paying for access to
individual ones, which clearly I can't justify. Neither am I
particularly good at maths, having never maths studied beyond that
needed for an engineering degree
A look at the Mathworld entry for the Prime Counting Function
http://mathworld.wolfram.com/PrimeCountingFunction.html
might give some clues as to the algorithm Mathematica uses. Although the
algorithm Mathematica is not stated in that Mathworld page, there are a
number of references. Two look interesting:
Mapes, D. C. "Fast Method for Computing the Number of Primes Less than a
Given Limit." Math. Comput. 17, 179-185, 1963.
Gourdon, X. "New Record Computation for pi(x), x=10^21." 27 Oct 2000.
http://listserv.nodak.edu/scripts/wa.exe?A2=ind0010&L=nmbrthry&P=2988
The link
http://listserv.nodak.edu/cgi-bin/wa.exe?A2=ind0010&L=nmbrthry&P=2988
states the algorithm used, but in a way I don't understand. It says:
"This value has been checked by computing pi(10^21+10^8) with
a different parameter y used in the algorithm"
But y is not defined! I'll try to drop the author of that post an email,
to see if he knows of any fast algorithm that might be applicable to the
general purpose case.
Since PrimePi[n] been computed to n=10^21 and both Mathematica and Sage
can't do PrimePi[10^15], there may well be a *lot* faster algorithm known.
Dave
For the record, here's the same thing in Sage. As you can see, it
took slightly less than 30 minutes on a macbook.
sage: time [[n, prime_pi(2^n)] for n in range(48)]
CPU times: user 1727.90 s, sys: 0.78 s, total: 1728.69 s
Wall time: 1737.05 s
[[0, 0],
[47, 4454203917918]]
And as mentioned before, the values up to 46 are correct, and the
value at 47 is wrong.
> PS, Mathematica computes PrimePi[some_negative_number] as 0. Does Sage
> handle that case ok?
>
sage: prime_pi(-20)
0
I personally can't see the point in stopping the algorithm working at
2^40, if it does work at 2^46. I realise you can't specifically test
2^46 on every occasion, but surely that argument could apply to sine,
cosine and every other function that exists. It's impractical to check
every single value that might be thrown at it. Of course, if there is
reason to believe the algorithm will fail, rather than just become very
slow, then there is good reason for putting a limit.
> * In 3.4.1 prime_pi() was completely broken for even 2^35 because len
> (prime_range(2^35)) aborts on sage.math since pari fails to allocate
> 124 *GB* of memory.
Em, but a failure to allocate sufficient memory should not cause a seg
fault - whether or not the memory allocation is sensible or not.
Perhaps this is why you are intending putting a limit. I can understand
that.
>>> * In 3.4.1 prime_pi() was completely broken for even 2^35 because len
>>> (prime_range(2^35)) aborts on sage.math since pari fails to allocate
>>> 124 *GB* of memory.
>> Em, but a failure to allocate sufficient memory should not cause a seg
>> fault - whether or not the memory allocation is sensible or not.
>
> Yeah, tell me. Either pari and/or Sage's pari interface sucks. It is
> absolutely ridiculous that pari seems to require that much memory, but
> it wouldn't be the first time we find an absolutely insane memory leak
> in pari.
>> Perhaps this is why you are intending putting a limit. I can understand
>> that.
>
> We are talking about two different limits here.
No, we were not - just a confusing way I wrote it. A memory alloction
issue is completely different to limiting an algorithm due to concerns
about it.
As a matter of interested, what does Sage give for
primepi(249999999999999)? Is it the same as Mathematica (7783516108362)?
It would be interesting if it gave the same result as Mathematica on any
of the computers.
In[95]:= PrimePi[249999999999999]
Out[95]= 7783516108362
Dave
The algorithm (and the definition of y) are given in the paper mentioned
in the same post:
Math Of Comp 1996 by Deleglise & Rivat : Computing Pi(x), the
Meissel, Lehmer, Lagarias, Miller, Odlyzko method.
I found an online copy: http://cr.yp.to/bib/1996/deleglise.pdf
Fredrik
Fredrik, Just out of curiosity, is that the sort of algorithm you like
to implement?
William
Quite possibly, but I'm not familiar with any of these algorithms so
I'd need some practice to implement anything even remotely optimized.
Perhaps something to look at during SD15? "Number Theory" is on the
official topic list
and this sounds very much like number theory.
Fredrik
I've used www.ustream.tv (although not on my computer), and it worked very well.
--Mike
That looks really good / easy: http://www.ustream.tv/get-started
Can 2 or 3 people who won't be at Sage Days respond and say they would actually
watch a live video stream from Sage Days, if I post one? If so, then
I'll do it (if not, I
won't waste the time).
-- William
It'd also be helpful for someone to volunteer to say watch IRC and
relay any questions from there to the live event.
--Mike
Good point! Thanks for volunteering! :P
(Sorry, couldn't resist.)
-cc
I am unlikely to watch a live stream but have watched several of the
posted videos after the fact.
Nick
Cool. One advantage for some people of the live stream is they will be able
to ask questions during the talk.
William
By the way, on a core2 2.66Ghz 13MB cache (sage.math) we have:
In[3]:= Timing[PrimePi[249999999999999]]
Out[3]= {155.44, 7783516108362}
So your timings above are significantly better than all general
purpose math software for
computing prime_pi.
William
Could you post a list of the sessions that you are planning on having?
I didn't find many things listed at http://wiki.sagemath.org/days15
I might be interested if the timing works out. In that case, it would
be good to have IRC access for questions.
Jason
I can't work out right now what time it will be in Melbourne during
these talks, but if it's not during my teaching/seminars/office hours
then I would happily watch a live video stream.
(So I guess my answer is pretty much isomorphic to Jason Grout's.)
Best,
Alex
I'd like to watch live (and ask questions via IRC, that would be nice),
but the time difference is annoying. (I'm 16 hours ahead of Seattle.)
I'd only be able to watch sessions starting late afternoon or later...if
there's a timetable, I can answer more accurately.
Dan
--
--- Dan Drake <dr...@kaist.edu>
----- KAIST Department of Mathematical Sciences
------- http://mathsci.kaist.ac.kr/~drake