1

I need to find integers $N_k$ such that, for example, $N_1 / \log{(2)} \approx N_2/ \log{(3)} \approx N_3/ \log{(5)} $ up to some specified precision. I posted this question on another forum and got a hint that the Lenstra-Lenstra-Lovasz (LLL) algorithm could be used. From a web search I found that Mathematica's LatticeReduce function implements LLL.

I would appreciate some help to set up LatticeReduce to solve this problem.

Thanks!

Accelerator
  • 4,923
Praveen B.
  • 91
  • 8

2 Answers2

2

The procedure is explained in this paper: https://arxiv.org/pdf/1705.01444.pdf

Choose a large number Q, e.g. 100000, that determines the target precision. You then create a matrix 'A' with the first row being $1, \lfloor Q\alpha_1 \rceil, \lfloor Q\alpha_2 \rceil, ...$ where the $\alpha_i$ are the real numbers you want to approximate. (Here $ \lfloor x \rceil$ denotes rounding off). The rest of the diagonal is filled with Q, while the remaining off-diagonals are all zero. Now take B=LatticeReduce[A] in Mathematica. The common denominator q for all the approximations is given by B[[1,1]].

Praveen B.
  • 91
  • 8
1

What you are looking for here is a vector with small coefficients in the lattice generated by the vectors $v_1=(\frac{1}{\log(2)},-\frac{1}{\log(3)},0)$, $v_2=(\frac{1}{\log(2)},0,-\frac{1}{\log(5)})$, and $v_3=(0,\frac{1}{\log(3)},-\frac{1}{\log(5)})$ : you want to find integers $N_2,N_3,N_5$ such that $N_2v_1+N_3v_2+N_5v_3$ has small coordinates.

Thus, if you apply the LLL algorithm on this lattice, the first vector of the basis produced by the algorithm will give you what you need.

I don't use Mathematica, but here is I would do it in PARI/GP : you just need to put the vectors in a matrix and call the qflll function from PARI/GP :

                                             GP/PARI CALCULATOR Version 2.11.2 (released)
                                     i386 running darwin (x86-64/GMP-6.1.2 kernel) 64-bit version
                                  compiled: Jun 16 2019, Apple LLVM version 9.1.0 (clang-902.0.39.2)
                                                       threading engine: single
                                            (readline v8.0 enabled, extended help enabled)
                                            Copyright (C) 2000-2018 The PARI Group

PARI/GP is free software, covered by the GNU General Public License, and comes WITHOUT ANY WARRANTY WHATSOEVER.

Type ? for help, \q to quit. Type ?17 for how to get moral (and possibly technical) support.

parisize = 8000000, primelimit = 500000 ? l2=(1/log(2)); ? l3=(1/log(3)); ? l5=(1/log(5)); ? may=matrix(3,3,i,j,0); ? may[1,1]=l2;may[1,2]=(-l3); ? may[2,1]=l2;may[2,3]=(-l5); ? may[3,2]=l3;may[3,3]=(-l5); ? answer=qflll(may) %8 = [-3267506153944191816322576846314409766534089074138558329585664023544025285769 345493278925783290743429096844560582371280878046881796014217490629159434721]

[-5178874724877153382533158453800874823072036524266542443093312820129451687533 547593891348561412702981655814494149582229668425724500323722946371683452164]

[-7586914339060369818888914394835323624136823978569380867715034054236327174428 802210550932532090893936378955011049007430964261807060895781045933178841691]

Here, the first column of the answer tells us that you can take $N_2=3267506153944191816322576846314409766534089074138558329585664023544025285769$, $N_3=5178874724877153382533158453800874823072036524266542443093312820129451687533$ and $N_5=7586914339060369818888914394835323624136823978569380867715034054236327174428$.

Ewan Delanoy
  • 61,600
  • I tried your code in the online (in-browser) version. I got a different answer. Also, how can I specify the precision here? The answer I got was:

    %1 = [204390084697119533884650729233815988426708784519130237472, 70594235787321253122855785995356164708763930612561774875; 323950619764155492231831737374075328865284625452540419821, 111889216489971631165763790827886537947561972906698224707; 474579079974649392041204919216978764667194611436114432768, 163914739411684093443592398041799806800313466288751196409]

    – Praveen B. Oct 21 '22 at 09:52
  • I'm not surprised you got a different answer, it must be because of the precision as you say. In my PARI/GP console, you set the precision with the \p command : for example, \p 30 sets the precision to 30 digits. Not sure if setting the precision is available on the online version though – Ewan Delanoy Oct 21 '22 at 10:12