1
$\begingroup$

I was looking for a way to derive the elements of the sequence in a different way in the Lucas–Lehmer test with $ \quad p \quad$an odd prime.

we know that $ \quad s_0=4 \quad $ and $ \quad s_i=s_{i-1}^2-2 \quad $ for $i>0 \quad$

$M_p=2^p-1 \quad$ is prime if $ \quad s_{p-2} \equiv 0 \bmod {(2^p-1)}$

if we use this sequence instead $ \quad L_i=s_{i-1}-2$

$ L_1=2 \quad $ and $ \quad L_i=L_{i-1}^2+4 \cdot {L_{i-1}} \quad $ for $i>1 \quad$

$M_p=2^p-1 \quad$ is prime if $ \quad L_{p-1} \equiv -2 \bmod {(2^p-1)}$

observing

$L_2=12=4 \cdot L_1^1+L_1^2=4 \cdot 2^1+2^2$

$L_3=192=16 \cdot L_1^1+20 \cdot L_1^2+8 \cdot L_1^3+1 \cdot L_1^4=16 \cdot 2^1+20 \cdot 2^2+8 \cdot 2^3+2^4$

$L_4=37632=64 \cdot L_1^1+336 \cdot L_1^2+672 \cdot L_1^3+660 \cdot L_1^4+352 \cdot L_1^5+104 \cdot L_1^6+16 \cdot L_1^7+1 \cdot L_1^8$

$L_5=256 \cdot L_1^1+5440 \cdot L_1^2+45696 \cdot L_1^3+201552 \cdot L_1^4+537472 \cdot L_1^5+940576 \cdot L_1^6+1136960 \cdot L_1^7+980628 \cdot L_1^8+615296 \cdot L_1^9+283360 \cdot L_1^{10}+95680 \cdot L_1^{11}+23400 \cdot L_1^{12}+4032 \cdot L_1^{13}+464 \cdot L_1^{14}+32 \cdot L_1^{15}+L_1^{16}$

$L_6=1024\cdot L_1^1+87296 \cdot L_1^2+2968064 \cdot L_1^3+53796160 \cdot L_1^4 + \cdots$

$\cdots$

you get

if $ \quad a_{m,i} \quad $ coefficient of $ \quad L_1^m=2^m \quad $ for element $ \quad {L_i}$

we have

$a_{1,i}=4^{i-1} \quad $ OEIS A000302

$a_{2,i}=20 \cdot a_{2,i-1} - 64 \cdot a_{2,i-2} \quad $ OEIS A166984

$a_{3,i}=\binom{2^{i-1}+2}{5} \cdot \frac{2^{i-1}}{3} \quad $ OEIS A040977 and A036563

$a_{4,i}=\binom{2^{i-1}+3}{7} \cdot \frac{2^{i-1}}{4} \quad $ OEIS A053347 and A028399

$\cdots$

Can it be useful to find all these sequences to get $ \quad L_{p-1} \quad $ more quickly?

EDIT

I don't know if the elementary reasoning is correct but

for example consider that $\quad a \cdot 2^p \equiv a \bmod {(2^p-1)}$

in general we have $\quad a \cdot 2^{k \cdot p} \equiv a \bmod {(2^p-1)}$

so $\quad a_{j,p-1}=\binom{2^{p-2}+j-1}{2 \cdot j-1} \cdot \frac{2^{p-2}}{j} $

and if $\quad j=k \cdot p \quad$ and consider that $ a_{k \cdot p,p-1} \cdot 2^{k \cdot p} \equiv a_{k \cdot p,p-1} \bmod {(2^p-1)} \equiv a_{k \cdot p,p-1} \cdot 2^0 \bmod {(2^p-1)}$

to get $L_{p-1} \bmod {(2^p-1)}$ we have

$a_{0,p-1} \bmod {(2^p-1)} \equiv \sum \limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{\binom{2^{p-2}+k \cdot p-1}{2 \cdot k \cdot p-1}\cdot \frac{2^{p-2}}{k \cdot p} } \quad \bmod {(2^p-1)}$

we can simplify

$\sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{\binom{2^{p-2}+k \cdot p-1}{2 \cdot k \cdot p-1} \cdot \frac{1}{4 \cdot k \cdot p}}$

$\sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{ \frac{(\frac{1}{4}+k \cdot p-1) \cdot (\frac{1}{4}+k \cdot p-2) \cdots \frac{1}{4} \cdots (\frac{1}{4}-k \cdot p+1)}{{(2 \cdot k \cdot p-1)}! \cdot 4 \cdot k \cdot p}}$

$\sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{ \frac{\prod\limits_{s=1}^{k \cdot p -1}{(1+4 \cdot k \cdot p -4 \cdot s) \cdot (1- 4 \cdot k \cdot p +4 \cdot s)}}{4^{2 \cdot k \cdot p-1} \cdot 4 \cdot k \cdot p \cdot {(2 \cdot k \cdot p -1)}!}}$

$\sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{ \left[ 2 \cdot\frac{\prod\limits_{s=1}^{k \cdot p -1}{(1+4 \cdot k \cdot p -4 \cdot s) \cdot (1- 4 \cdot k \cdot p +4 \cdot s)}}{2^{4 \cdot k \cdot p} \cdot 2\cdot k \cdot p \cdot {(2 \cdot k \cdot p -1)}!}\right]}$

$\sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{\left[(-1)^{(k \cdot p -1)} \cdot 2 \cdot \frac{\prod\limits_{s=1}^{k \cdot p -1}{(4 \cdot k \cdot p -4 \cdot s+1) \cdot (4 \cdot k \cdot p -4 \cdot s-1)} }{ {(2 \cdot k \cdot p )}!}\right]}$

$\sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{\left[(-1)^{(k \cdot p -1)} \cdot 2 \cdot \frac{\prod\limits_{s=1}^{2\cdot (k \cdot p-1)}{(4 \cdot k \cdot p -2 \cdot s-1)} }{ { (2 \cdot k \cdot p )}!}\right]}$

$\sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{\left[(-1)^{(k \cdot p -1)} \cdot 2 \cdot \frac{{(4 \cdot k \cdot p-3 )}! }{ (2 \cdot k \cdot p )! \cdot \prod\limits_{s=1}^{2 \cdot k \cdot p-2}{2 \cdot s} }\right]}$

$\sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{\left[(-1)^{(k \cdot p -1)} \cdot 8 \cdot \frac{{(4 \cdot k \cdot p-3 )}! }{ (2 \cdot k \cdot p )! \cdot 2^{2 \cdot k \cdot p} \cdot \prod\limits_{s=1}^{2 \cdot k \cdot p-2}{ s} }\right]}$

so

$a_{0,p-1} \bmod {(2^p-1)} \equiv \sum\limits_{k=1}^{\lfloor{2^{p-2}}/{p}\rfloor}{\left[\frac{4 \cdot (-1)^{(k \cdot p -1)} }{ k \cdot p } \cdot \binom{ 4 \cdot k \cdot p-3 }{ 2 \cdot k \cdot p-1 }\right]} \quad \bmod {(2^p-1)}$

if $p=5$ in $L_4$ we have $a_{5,4}=352$

then $352\cdot 2^5 \bmod 31 \equiv 352 \bmod 31=11 \quad$ which corresponds to $a_{0,4} \bmod 31$

but also $\lfloor\frac{2^{5-2}}{5}\rfloor=1$ we can calculate the modulo of $ a_{0,4} \bmod 31 \quad $so

$a_{0,4} \bmod {31} \equiv \left[\frac{4}{5} \cdot \binom{17}{9}\right] \bmod {31}=19448 \bmod {31}=11$

In general $a_{j,p-1}=\sum{(\cdots)} \quad$ extending the procedure for $0 \leq j \leq p-1$ should simplify the computation of $L_{p-1} \bmod {(2^p-1)}$ if it is possible to simplify the summation to the calculation of a single term.

EDIT

In theory, if the reasoning is correct it should be:

$s_{p-2}=(2^{2 \cdot (p-2)}+1)\cdot 2^1+\binom{2^{p-2}+1}{3} \cdot \frac{2^{p-2}}{2}\cdot 2^2+\cdots+ \binom{2^{p-2}+j-1}{2 \cdot j-1} \cdot \frac{2^{p-2}}{j}\cdot 2^j+\cdots+2^{p-1}\cdot 2^{(2^{p-2}-1)}+2^{2^{p-2}}$

Is there a way to simplify the calculation of $\quad s_{p-2} \bmod {(2^p-1)}$?

$\endgroup$
4
  • $\begingroup$ We can take the intermediate results modulo the given Mersenne number. I do not think that there are further shortcuts making the proceudre significantly more efficient. $\endgroup$
    – Peter
    Aug 28, 2022 at 12:58
  • $\begingroup$ @Peter I know this but we also know that $2^{b \cdot p} = 1 \bmod {(2^p -1)}$ and we have $2^{a + b \cdot p} = 2^a \cdot(2^{b \cdot p} -1) + 2^a$ and $c\cdot 2^{p-1} = c/2 \cdot (2^p -1) + c/2 $. In this way, if we calculate directly the coefficients of $ L_{p-1}$ we can calculate the modulo quickly. $\endgroup$
    – user140242
    Aug 28, 2022 at 13:08
  • $\begingroup$ Is there supposed to be a relationship between sequences $\{s_k\}$ and $\{L_k\}$? Also, with $p=2$ you posit that $L_{p-1} \equiv -2 \bmod (2^p-1)$ where by definition $L_1 = 2$. But $2 \not\equiv -2 \bmod 3$. $\endgroup$
    – hardmath
    Aug 28, 2022 at 14:11
  • $\begingroup$ @hardmath Yes $\quad L_i $ = $ s_{i-1}-2 \quad$ but also $ \quad4 \not \equiv 0 \bmod 3 $ $\endgroup$
    – user140242
    Aug 28, 2022 at 14:19

0

You must log in to answer this question.