You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
David Bailey's ARPREC package http://crd.lbl.gov/~dhbailey/mpdist/
includes several implementations of PSLQ, written in C++, and is
licensed under BSD. However, ARPREC raw multi arithmetic timings
don't look too favorable http://pari.math.u-bordeaux.fr/benchs/timings-mpfr.html and one has the same fix-x86 issues as quad-double.
It looks like, however, one of the advantages of PSLQ is that it does
not require full-precision at many of the intermediate steps. (that's
what this two-level stuff is about in his package--most operations
are performed with machine-double arithmetic).
Zimmermann also has a GPL implementation, based on gmp, which is only 1000 lines long. No idea yet how speeds compare.
Damien Stehle did some comparisons between the PSLQ implementation of Bailey and his FPLLL, and
FPLLL was much faster. Of course it would be good to have an independent comparison, but it might
be that PSLQ does not outperform LLL when searching for linear relations.
I've attached the code/paper that was attached to the following email.
agnes.jany@googlemail.com>
to wstein@gmail.com
date Mon, Aug 10, 2009 at 2:16 PM
subject PSLQ implementation
mailed-by googlemail.com
hide details 2:16 PM (1 hour ago)
Reply
Follow up message
Dear Mr Stein,
I'm a mathematics student at the Johannes-Gutenberg University of Mainz, Germany.
As a part of my diploma thesis, I have implemented PSLQ to SAGE. You can find
the code, a worksheet and a documentation in the attachment of this email. Maybe
you can use my work for your project.
Yours sincerely,
Agnes Jany
The first one says that the only integer relation between the square roots of 2,3,...,8 is 2\sqrt{2}-\sqrt{8}=0. The second is one of the cool formulas expressing pi as a combination of arccotangents.
The mpmath implementation should be correct, but it doesn't implement all the stopping criteria, and sometimes the precision, tolerance and iteration settings need fiddling with to give the right result. So even ignoring speed, it would be desirable for Sage to use an implementation that gives good control over all the settings.
The 20x difference actually sounds a bit high (though not unrealistic). I wonder if the number of iterations is the same for both implementations (it could be quite different depending just on small implementation details). Also, on my computer, PSLQ runs about twice as fast with mpmath+gmpy than mpmath+Sage.
I don't know how the other implementations compare, but I would favor adding e.g. Paul Zimmermann's implementation to Sage. It should be trivial to wrap mpmath.pslq as well, so perhaps it could be provided as an optional algorithm.
I have also started writing an interface for using this from Sage, see the attached patch trac_853.patch. This is obviously not done: for one, there should be way more docstrings and doctests. However, I would like some feedback on the interface before I put much more work into this. If somebody has a cleaner way of using PSLQ from Sage, I'm happy to listen and throw away what I've done so far.
Just a note on ARPREC's license, since Paul brought it up: it is not BSD as stated in this ticket's description, rather BSD-LBNL. However, this is apparently compatible with both GPLv2 and GPLv3, according to the table "Good licenses" at
How much work would that be to interface your C code with Sage ? Do you have a proof of concept ?
no idea. Why do you ask? See comment [comment:2]. I see no reason to interface PSLQ.
I'm at a small workshop and there is someone which is currently using Maple and is considering to switch to Sage.. Maple has both LLL and PSLQ. He told me that, he has some stability problem with LLL, in the sense that removing some precision digits gives drastically different results. Apparently PSLQ doesn't. I've no idea if it's a problem with the algorithms or the implementation.
This past January, a student of mine and I have run some experiments comparing fpLLL and the PSLQ implementations from ARPREC (we wanted to take the best current implementations to get a realistic comparison). In the examples we ran, we found almost no reason to use PSLQ instead of fpLLL for finding integer relations. The only situation where PSLQ might be more appropriate is when it is extremely expensive to generate extra digits in the input floating point numbers. PSLQ has a slight edge here because it tends to require fewer digits of precision than fpLLL. Most of the time this is of no consequence because fpLLL is much faster. We'll try to write something up describing our experiments and results, but I don't know how soon I'll find time for that.
In terms of "stability", our experiments indicate that PSLQ tends to stick with the correct answer once it finds it, as you add more digits of precision. With fpLLL, you sometimes hit the right answer with, say 190 digits, but then you get different answers for a short while (say, 191 to 197 digits), and then it stabilises on the right answer again. Paul, I can dig up an explicit example of this if you are interested. Again, I don't see this as an issue from a practical point of view -- I would run the algorithm until I get the exact same answer with 3 or 5 different precisions.
Activity
williamstein commentedon Oct 12, 2007
zimmermann6 commentedon Nov 16, 2007
Damien Stehle did some comparisons between the PSLQ implementation of Bailey and his FPLLL, and
FPLLL was much faster. Of course it would be good to have an independent comparison, but it might
be that PSLQ does not outperform LLL when searching for linear relations.
wdjoyner commentedon May 7, 2009
To be precise, Zimmerman's code is at http://www.loria.fr/~zimmerma/free/pslq-1.0.c and is licensed under the GPLv2+.
williamstein commentedon Aug 10, 2009
I've attached the code/paper that was attached to the following email.
aghitza commentedon Nov 29, 2009
Attachment: pslqimplementation.zip
Note that mpmath, which is now a standard Sage package, contains an implementation of pslq:
The examples are from the mpmath documentation, see http://mpmath.googlecode.com/svn/trunk/doc/build/identification.html
The first one says that the only integer relation between the square roots of 2,3,...,8 is
2\sqrt{2}-\sqrt{8}=0. The second is one of the cool formulas expressing pi as a combination of arccotangents.aghitza commentedon Nov 29, 2009
It would still be worth it to wrap Paul Zimmermann's C implementation, since it's fast. I tried it together with the mpmath implementation on the real life example given at the top of http://www.cecm.sfu.ca/organics/papers/bailey/paper/html/node6.html
Both give the right answer (yay!). According to timeit:
Zimmermann's C implementation:
mpmath's implementation:
So the C code is 20 times faster in this example.
fredrik-johansson commentedon Nov 30, 2009
The mpmath implementation should be correct, but it doesn't implement all the stopping criteria, and sometimes the precision, tolerance and iteration settings need fiddling with to give the right result. So even ignoring speed, it would be desirable for Sage to use an implementation that gives good control over all the settings.
The 20x difference actually sounds a bit high (though not unrealistic). I wonder if the number of iterations is the same for both implementations (it could be quite different depending just on small implementation details). Also, on my computer, PSLQ runs about twice as fast with mpmath+gmpy than mpmath+Sage.
I don't know how the other implementations compare, but I would favor adding e.g. Paul Zimmermann's implementation to Sage. It should be trivial to wrap mpmath.pslq as well, so perhaps it could be provided as an optional algorithm.
aghitza commentedon Feb 21, 2010
Author: Paul Zimmermann, Alex Ghitza
aghitza commentedon Feb 21, 2010
I have created an spkg for Paul Zimmermann's C implementation of PSLQ, see
http://sage.math.washington.edu/home/ghitza/pslq-1.0.spkg
I have also started writing an interface for using this from Sage, see the attached patch
trac_853.patch. This is obviously not done: for one, there should be way more docstrings and doctests. However, I would like some feedback on the interface before I put much more work into this. If somebody has a cleaner way of using PSLQ from Sage, I'm happy to listen and throw away what I've done so far.I'm about to ask for feedback on sage-devel.
16 remaining items
aghitza commentedon Feb 24, 2010
Just a note on ARPREC's license, since Paul brought it up: it is not BSD as stated in this ticket's description, rather BSD-LBNL. However, this is apparently compatible with both GPLv2 and GPLv3, according to the table "Good licenses" at
http://fedoraproject.org/wiki/Licensing
So there should be no legal obstacles to using ARPREC.
aghitza commentedon Sep 10, 2011
hivert commentedon Jun 20, 2012
Hi Paul,
How much work would that be to interface your C code with Sage ? Do you have a proof of concept ?
Florent
zimmermann6 commentedon Jun 20, 2012
Replying to @hivert:
no idea. Why do you ask? See comment [comment:2]. I see no reason to interface PSLQ.
Paul
hivert commentedon Jun 20, 2012
Replying to @zimmermann6:
I'm at a small workshop and there is someone which is currently using Maple and is considering to switch to Sage.. Maple has both LLL and PSLQ. He told me that, he has some stability problem with LLL, in the sense that removing some precision digits gives drastically different results. Apparently PSLQ doesn't. I've no idea if it's a problem with the algorithms or the implementation.
zimmermann6 commentedon Jun 20, 2012
I'm curious seeing an example with some stability problem with LLL.
Paul
aghitza commentedon Jun 21, 2012
This past January, a student of mine and I have run some experiments comparing fpLLL and the PSLQ implementations from ARPREC (we wanted to take the best current implementations to get a realistic comparison). In the examples we ran, we found almost no reason to use PSLQ instead of fpLLL for finding integer relations. The only situation where PSLQ might be more appropriate is when it is extremely expensive to generate extra digits in the input floating point numbers. PSLQ has a slight edge here because it tends to require fewer digits of precision than fpLLL. Most of the time this is of no consequence because fpLLL is much faster. We'll try to write something up describing our experiments and results, but I don't know how soon I'll find time for that.
In terms of "stability", our experiments indicate that PSLQ tends to stick with the correct answer once it finds it, as you add more digits of precision. With fpLLL, you sometimes hit the right answer with, say 190 digits, but then you get different answers for a short while (say, 191 to 197 digits), and then it stabilises on the right answer again. Paul, I can dig up an explicit example of this if you are interested. Again, I don't see this as an issue from a practical point of view -- I would run the algorithm until I get the exact same answer with 3 or 5 different precisions.
zimmermann6 commentedon Jun 21, 2012
Alex,
yes please do! Such explicit examples are extremely useful.
Paul
kcrisman commentedon Nov 19, 2014
Any news on this ticket?
zimmermann6 commentedon Nov 19, 2014
I don't know what information was missing in comment [comment:9], but the following reference might be useful: http://dl.acm.org/citation.cfm?id=2465936
Paul
kcrisman commentedon Dec 19, 2014
See also http://math.stackexchange.com/questions/853339/ which seems quite relevant.
Do we actually have one in Sage currently, by the way? A new user implied we might, just not a very powerful one.
fchapoton commentedon May 13, 2020
whoami730 commentedon Jul 17, 2025
I think we still do need PSLQ in sagemath.
sagemathgh-43136: build(deps): bump softprops/action-gh-release from …