New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faster high-precision logarithms #87
Comments
I was looking at this issue, and perhaps I'm not understanding what you mean. What do you mean by "n-smooth rational approximation"? Do you have a reference where this is defined? |
I'm not @fredrik-johansson, but I think "n-smooth rational approximation" is supposed to mean "rational approximation that factors into primes <= n". If that's the case, it's quite a nasty problem (or I'm just blind to the "obvious" solution, as usual). I found the following "algorithm", which might or might not be useful (in this example we use 2,3,5 and 7):
It's not very fast, but still faster than using a square root to reduce the argument. If you want more of these "esoteric" fractions, I wrote a program (not on Github, but it's trivial) that finds (probably all) fractions of the form (n+1)/n that factor into primes smaller than a given bound. It seems there are only finitely many of these (and that's very plausible) but I haven't looked for a proof yet. |
I had somehow forgotten about this. @simonpuchert Your method seems promising. Do you have some code to experiment with (no need to actually compute the logs; just for the approximation problem)? There is also a brute force solution: precompute a table of all 7-smooth numbers up to some bound, sorted. For each n in the table, try to use it as a denominator and use bisection to find a numerator. Find the best approximation this way. (There should be some tricks to speed up the search by avoiding common factors.) I'm quite sure that this will work, but I can't tell how it compares to your method. |
By the way, I suspect this will not actually be faster than the AGM. But it would be interesting to see how far it can be pushed. |
I think I see how to make this work now. Essentially using Simon's strategy, but a much larger table of smooth fractions for reduction can be precomputed using LLL. I will try some implementation experiments. |
This is now implemented for exp and log and does give roughly a 2x speedup (much better than I had hoped for). Still working on a trigonometric version. |
The only problem now is that Appveyor tests are failing, for who knows what reason. |
Done. |
Idea: with log(2), log(3), log(5) (and maybe log(7)) precomputed, quickly determine a 5-smooth (or 7-smooth) rational approximation of x.
Hypothesis: if 10-20 bits of argument reduction can be achieved quickly, it ought to make the bit-burst algorithm faster than the AGM for log.
Bonus: instant logarithms of smooth integers.
Can the same trick speed up the argument reduction for other elementary functions?
The text was updated successfully, but these errors were encountered: