4

Primorial number system is a number sytem that uses primorials which are defined as follows :

Let $p_1=2, p_2=3,p_3=5,p_4=7,p_5=11,...$ the primes. The sequence of primorials, noted $p_n\#$ is $$(p_n\#)_{n\geq 1}=(2,2.3=6,2.3.5=30,2.3.5.7=210,210.11=2310,...$$

For example, we write $15$ and $28$ as $$15=2\times 6+1\times 2+1=(2:1:1)$$ $$28=(4:2:0)$$

I'm trying to think with your help hopefully about a multiplication algorithm of positive integers written in Primorial number system(two steps 1 and 2).


1.- Calculate congruences modulo any prime number via this number system, is very easy : for example, any integer like $(\color{green}{...:1:2:5:2:1:6:9:1:1:}\color{red}{0:0:2:1:1})$ is such that $$(\color{green}{...:6:9:1:1:}\color{red}{0:0:2:1:1})\equiv \color{green}{0+}\color{red}{0\times1+0\times 8+2\times 6+1\times 2+1\times 1 }\equiv 4 (\mod 11) $$since $2310\equiv 0 , 210\equiv 1 , 30\equiv 8 ,6\equiv 6, 2\equiv 2, 1\equiv 1 (\mod 11)$

So, $$\begin{cases} (2:1:1)\equiv \color{blue}{1,0,0,1,4} \mod 2,3,5,7,11\\ \land \\ (4:2:0)\equiv \color{blue}{0,1,3,0,6} \mod 2,3,5,7,11 \end{cases}$$

I took small integers but the same method works for integers with $\color{green}{\text{several hundred digits}}$ in base two.

2.- My idea to multiply $(2:1:1)$ and $(4:2:0))$ is then to use Chinese Remainder theorem once we have realized that $$P:=(2:1:1)\times (4:2:0)<2310\color{red}{(*)}$$

We obtain $$P\equiv \color{blue}{0,0,0,0,2} \mod 2,3,5,7,11$$ Then $\exists k, P=210k \land 210k=2 \text{ in } \mathbb Z/11\mathbb Z \iff 1k=2 \iff k=2$ And finally $$\boxed {P=(2:1:1)\times (4:2:0)=(2:0:0:0:0)}$$


a. Is that correct ? In particular $\color{red}{(*)}$ should probably be clarified

b. Switching from primorial numeral to base ten or two is easy. $$P=(2:1:1)\times (4:2:0)\to 15\times 28=420 \to (2:0:0:0:0)$$

is a procedure which, at first glance, seems sufficient. Nevertheless, I think that the question arises as to whether this basic procedure is really sufficient, since I have mentioned $\color{green}{\text{several hundred digits}}$(A bit random I admit) and wondered whether we could not rather say several thousand or even more.


Edit: To partially reply to the comment by @Steven Clark, here is another example $P=ab$, with $a=(...:c:b:a:0:1:9:6:2:2:1)\equiv 1,2,2,1,8,3,11$ and $b=(...:\gamma:\beta:\alpha:0:3:4:4:0:1:1)\equiv 1,0,3,4,6,2,5\mod 2,3,5,7,11,13,17$.

$P=\color{blue}1+2k_0. 1+2k_0=0 \text{ in }Z/3\implies k_0=\color{blue}1+3k_1. P=1+2(1+3k_1)=3+6k_1. P=3+1k_1 \text{ in }Z/5\implies k_1=3+5k_2. P=\color{blue}1\times 1+\color{blue}1\times 2+\color{blue}3\times 6 +30k_2. P=0+2k_2 \text{ in }Z/7\implies k_2=2+7k_3. P=\color{blue}1\times 1+\color{blue}1\times 2+\color{blue}3\times 6 +\color{blue}2 \times 30+210k_3...$

So, $$P=(...:\color{blue}{2:3:1:1})$$ (example constructed with $4\,397\times 7\,893=34\,705\,521$)

  • 1
    Have you tried the multiplication method for random numbers with $100$ digits ? – Peter Apr 07 '24 at 08:23
  • I meant $100$ digits in the decimal expansion. – Peter Apr 07 '24 at 09:03
  • 1
    Your example $15 \cdot 28=420=2, p_4#$ seems rather artificially constructed, and I find your description rather hard to follow. Perhaps posting your Python code would help clarify your algorithm, but I fail to see why your two step algorithm would be any more efficient than simply converting back and forth between the primorial number system and base 2 or 10 representations as mentioned in b. – Steven Clark Apr 10 '24 at 00:49
  • @Steven Clark : You are right. But as you've seen, I'm using multiplication as part of another algorithm. In this algorithm, multiplications are redundant. To multiply two 100-digit numbers, as the previous calculations have already been done, I only need 4/5 operations. I say numbers a bit randomly not being a fan of programming, and having only been introduced to python for that. – Stéphane Jaouen Apr 10 '24 at 06:15
  • It seems to me for $a \cdot b=c$ your multiplication algorithm consists of the following steps: 1) convert $a$ and $b$ into primorial representation; 2) compute residues of $a$ and $b$ mod small primes; 3) multiply residues of $a$ and $b$ mod small primes together to determine residues of $c$ mod small primes; 4) use Chinese remainder theorem to determine $c$ from residues of $c$ mod small primes; 5) convert $c$ into primorial representation. Is this correct? – Steven Clark Apr 11 '24 at 17:15
  • 1
    It seems to me you're not really multiplying in the primorial representation, rather for $a \cdot b=c$ your multiplication algorithm just adds extra steps to this simpler algorithm: 1) compute residues of $a$ and $b$ mod small primes; 2) multiply residues of $a$ and $b$ mod small primes together to determine residues of $c$ mod small primes; 3) use Chinese remainder theorem to determine $c$ from residues of $c$ mod small primes. – Steven Clark Apr 11 '24 at 17:35
  • Its true you can convert to the small prime residue representation from the primorial representation, but this can also easily be done directly from the decimal representation. And when you use the Chinese remainder theorem, do you first determine the result in base ten and then convert it to the primorial representation? – Steven Clark Apr 11 '24 at 17:35
  • No, exactly. What is remarkable is the link between the modular system associated with these cases and primorial numeration. And I wonder if this intrinsic link has ever been observed . And I'm not just interested in small numbers. – Stéphane Jaouen Apr 11 '24 at 17:38
  • 1
    I don't understand the example in your edit. You indicate for $P=a \times b=4,397 \times 7,893=34,705,521$ the residue representation of $b=7,893$ is $1, 0, 1, 4, 4, 6, 4$ whereas I get $1, 0, 3, 4, 6, 2, 5$. Also, what is your definition of $Z$ and what do you mean by $Z/3$? Is $Z/3$ the same thing as $(\bmod 3)$? – Steven Clark Apr 27 '24 at 15:37
  • https://en.wikipedia.org/wiki/Modular_arithmetic#Integers_modulo_n – Stéphane Jaouen Apr 27 '24 at 16:26

1 Answers1

1

Your algorithm isn't clear to me from your description, so I'll give an algorithm and hopefully you can clarify if your algoritrhm is the same or how it differs.


Assuming

$$a=\sum\limits_{j=0}^A a_j\, p_j\#=\{a_0, a_1, ..., a_A\}\tag{1}$$

and

$$b=\sum\limits_{j=0}^B b_j\, p_j\#=\{b_0, b_1, ..., b_B\}\tag{2}$$

then I believe

$$c=a\times b=\sum\limits_{j=0}^A \left(a_j\, p_j\#\, \sum\limits_{k=0}^B b_k\, p_k\#\right)\tag{3}.$$


Formula (3) above gives a normal numerical result, but this can easily be converted back into the primorial representation

$$c=\sum\limits_{j=0}^C c_j\, p_j\#=\{c_0, c_1, ..., c_C\}\tag{4}$$

if desired.


Could you please give a more generic description of your algorithm for $a\times b$ where $a$ and $b$ are defined in formulas (1) and (2) above? Perhaps the simple case $\left\{a_0, a_1, a_2\right\} \times \left\{b_0, b_1, b_2\right\}$ would provide some clarification because in your numeric example I don't understand where/how you're getting your numbers or applying the Chinese remainder theorem.

Steven Clark
  • 8,744
  • @StéphaneJaouen You've given an example of some numerical calculations which are obscure to me, so please define your algorithm for $a \times b=c$ in terms of the primorial coefficients $a_n$ and $b_n$ where for example $a=\left{a_0, a_1, a_2\right}$ and $b=\left{b_0, b_1, b_2\right}$ are the primorial representations of $a$ and $b$ and the mod-prime congruence coefficients $A_{p_n}=a, (\bmod p_n)$ and $B_{p_n}=b, (\bmod p_n)$ where $a=\left{A_2, A_3, A_5, A_7, A_{11}\right}$ and $b=\left{B_2, B_3, B_5, B_7, B_{11}\right}$ are the mod-prime congruence representations of $a$ and $b$. – Steven Clark Apr 26 '24 at 20:16
  • @StéphaneJaouen I understand how to calculate modular arithmetic, but I'm not sure I understand your point. In your example of calculating $4, (\bmod 11)$ it seemed to me the first step was converting from the primorial representation to the normal numerical representation. – Steven Clark Apr 26 '24 at 20:25
  • @StéphaneJaouen You just illustrated my point as $(2:1:1)=2\times 6+1\times 2+1\times 1=15$ is exactly the conversion I was talking about which leads to $15=4, (\bmod 11)$. – Steven Clark Apr 26 '24 at 20:34
  • @StéphaneJaouen I know how to get to the mod-prime congruence representations of $a$ and $b$ independent of the primorial representations of $a$ and $b$, but perhaps you're also performing conversions on intermediate results during your algorithm for calculating $c=a \times b$? – Steven Clark Apr 26 '24 at 20:43
  • @StéphaneJaouen Are you're really multiplying in the mod-prime congruence representation instead of the primorial representation, and then converting to the primorial representation at the end? If so, what's the point of converting from the numerical representation to the primorial representation at the beginning and from the mod-prime congruence representation to the primorial representation at the end? – Steven Clark Apr 26 '24 at 21:21
  • @StéphaneJaouen I was hoping your multiplication algorithm would provide some insight into how your factorization algorithm works (which is really my primary interest). You provided a numerical example in your related question on factorization and added a numerical example in your edit to this question, but I'm having problems reverse engineering your algorithms from either of these two numerical examples. So I was hoping you could provide mathematical definitions of your algorithms analogous to formula (3) in my answer above instead of giving numerical examples of their implementations. – Steven Clark Apr 27 '24 at 02:43
  • @StéphaneJaouen I've worked through and I believe I understand your multiplication algorithm now, but I believe you're really multiplying in the residue representation and the algorithm you give here is really a conversion algorithm from the residue representation to the primorial representation. So I'm wondering if your factorization algorithm also really just uses the residue representation, and the conversion from the residue representation to the primorial representation is just an intermediate step in the conversion from the residue representation to the numerical representation. – Steven Clark Apr 28 '24 at 17:56
  • The idea is that we may have to do thousands of multiplications. But as multiplications sometimes use the same first coefficients, the step concerning these coefficients is done only once. So we can do multiplications of very large numbers with only a few small calculations. – Stéphane Jaouen Apr 28 '24 at 19:42