Wednesday, December 06, 2017

[ucoabwxh] Square roots summing to almost integers

How close to an integer can a sum of square roots be?  We investigate integer linear combinations of square roots of squarefree integers.

Using the squarefree integers up to 15 and coefficients between -15 and +15, the best almost-integer is

11*sqrt(2) - 10*sqrt(3) + 9*sqrt(5) - 5*sqrt(6) + 3*sqrt(7) + 6*sqrt(10) + 9*sqrt(11) + 8*sqrt(13) + 8*sqrt(14) + 13*sqrt(15) - 172 = 7.2e-16

Using the squarefree integers up to 53 and coefficients between -1 and +1, the best is

-sqrt(2) - sqrt(3) - sqrt(7) - sqrt(10) + sqrt(11) - sqrt(13) + sqrt(14) - sqrt(15) - sqrt(17) - sqrt(19) - sqrt(21) - sqrt(22) + sqrt(23) + sqrt(29) - sqrt(30) + sqrt(34) - sqrt(35) + sqrt(37) - sqrt(38) - sqrt(39) + sqrt(43) + sqrt(53) + 15 = -4.9e-17

We did a partial search with squarefree integers up to 17 and coefficients between -17 and +17.  We constrained the first coefficient, that of sqrt(2), to -17.  The best found was

-17*sqrt(2) - 14*sqrt(3) + 2*sqrt(5) + 3*sqrt(6) - 11*sqrt(7) + 7*sqrt(10) + 14*sqrt(11) - 8*sqrt(13) + 2*sqrt(14) + sqrt(15) + 4*sqrt(17) - 2 = -2.5e-17

Finding this last one took about 21 days on a single processor.  Other results, less close to integers, and source code are available here.

There are many opportunities for optimization for this problem.  We implemented the following two.  Instead of writing a program, we wrote a program (in Perl) to generate a program (in C++).  We did the calculations with 64-bit fixed point instead of double-precision.

This project was inspired by generating irrational numbers.

No comments :