2

Okay working in base $b$ we are given a fraction of form $\frac{p}{q}$ with $p$ and $q$ coprime. We also assume that $b$ and $q$ are coprime so $\frac{p}{q}$ is purely periodic in base $b$. The question I have is what can I say about this period. How tight of bounds can I get on it in terms of $q$?

I know that for an upper bound I have $q-1$, or at least I think I do.

For the lower bound I know I have $\frac{\log(q)}{log(b)}$.

So the range I have for the length of the period is $q - \frac{\log(q)}{\log(b)} - 1$ which is $O(q)$ is there a better bound I can put on it? I'd like $O(\log(q))$

This is related to Length of period of decimal expansion of a fraction but a more general question I believe

ruler501
  • 1,218

1 Answers1

2

For any three integers $m,n,b$ such that

$$m \ge 1,\quad n, b > 1\quad\text{ and }\quad\gcd(m,n) = \gcd(m,b) = \gcd(n,b) = 1$$

Let $\displaystyle\;\tau\left(\frac{m}{n}, b\right)\;$ be the "period" of the expansion of $\displaystyle\;\frac{m}{n}\;$ in base $b$.

Let $\lambda = \lambda(n)$ be the value of Carmichael function for $n$, we have

$$\gcd(b,n) = 1 \quad\implies\quad b^\lambda \equiv 1 \pmod n \quad\iff\quad n\;|\;b^\lambda - 1$$ Let $\displaystyle\;k = \frac{b^\lambda - 1}{n} \in \mathbb{Z}_{+}\;$, we have

$$\frac{m}{n} = \frac{km}{b^\lambda - 1} = km\sum_{\ell=1}^\infty b^{-\ell\lambda} \quad\implies\quad\left.\tau\left( \frac{m}{n}, b \right) \right| \lambda.$$

This means $\lambda(n)$ is an upper bound for $\displaystyle\;\tau\left(\frac{m}{n}, b\right)\;$ for any choice of $m$ and $b$.

Update

In general, let $\mathbb{Z}_n^\times$ be the multiplicative subgroup of $\mathbb{Z}/\mathbb{nZ}$ consists of ( equivalent classes of ) integers relative prime to $n$. Let $\mu = \text{ord}_n(b)$ be the order of $b$ in $\mathbb{Z}_n^\times$ (also known as multiplicative order or haupt-exponent of $b \pmod n$). Using same argument as above, we get

$$n | b^\mu - 1 \quad\implies\quad \left.\tau\left( \frac{m}{n}, b \right) \right| \text{ord}_n(b)\tag{*1a}$$

On the other direction, let $\displaystyle\;\nu = \tau\left( \frac{1}{n}, b \right)\;$. Being a period for the expansion of $\displaystyle\;\frac{1}{n}\;$ in base $b$, we can find integers $\alpha, A, B$ such that

$$\frac{1}{n} = \frac{1}{b^\alpha}\left[ A + \frac{B}{b^\nu - 1}\right], \quad \alpha \ge 0, A \ge 0, b^\nu - 1 > B > 0$$

It is clear $\displaystyle\;A = \left\lfloor\frac{b^\alpha}{n}\right\rfloor$. Introduce $C$ such that $b^\alpha = A n + C$, we can rewrite above condition as

$$\frac{C}{n} = \frac{B}{b^\nu - 1}\quad\iff\quad Bn = C(b^\nu - 1) \quad\implies\quad n | C(b^\nu - 1) $$

Since $\gcd(C,n) = \gcd(b^\alpha - An, n) = \gcd(b^\alpha,n) = 1$, this leads to

$$n | b^\nu - 1 \quad\implies\quad \left.\tau\left(\frac{1}{n},b\right)\right| \text{ord}_n(b)\tag{*1b}$$

Combine $(*1a)$ and $(*1b)$, we get

$$\tau\left(\frac{1}{n},b\right) = \text{ord}_n(b) \quad\implies\quad \max\left\{\; \tau\left( \frac{m}{n}, b \right) : m \ge 1 \;\right\} = \text{ord}_n(b) $$ i.e. $\text{ord}_n(b)$ is the least upper bound of $\displaystyle\;\tau\left(\frac{m}{n},b\right)\;$ when we fix $b$ and allow $m$ to vary.

Let $n = p_1^{e_1} p_2^{e_2} \cdots p_r^{e_r}$ be the factorization of $n$ into its prime factors. We know as a group, $\mathbb{Z}_n^\times$ is isomorphic to the direct product of its prime components.

$$\mathbb{Z}_n^\times = \mathbb{Z}_{p_1^{e_1}}^\times \times \mathbb{Z}_{p_2^{e_2}}^\times \times \cdots \mathbb{Z}_{p_r^{e_r}}^\times$$

The carmichael function of $n$ can be expressed in terms of its prime components

$$\lambda(n) = \text{lcm}( \lambda( p_1^{e_1} ), \lambda( p_2^{e_2} ), \cdots, \lambda( p_r^{e_r} ) )$$ We also know inside each $\mathbb{Z}_{p_i^{e_i}}^\times$, there is a element whose order equal to $\lambda( p_i^{e_i} )$. We can use Chinese remainder theorem to assemble these elements into an element $a \in \mathbb{Z}_{n}^\times$ such that $$ \text{ord}_n(a) = \lambda(n) \quad\implies\quad\tau\left(\frac{1}{n}, a \right) = \lambda(n) $$

What this means is $\lambda(n)$ is not just a upper bound for $\displaystyle\;\tau\left(\frac{m}{n},b\right)\;$, it is the least upper bound when we allow both $m$ and $b$ to vary.

Conclusion - If we don't impose more constraint on $b$, $\lambda(n)$ is the best bound we can have.

Update 2

About the question what sort of bound we will have when $b = 3$, I have performed some numerical experiment. The result indicate the period

$$\tau_n \stackrel{def}{=} \tau(\frac{1}{n},3) = \text{ord}_n(3) =\text{lcm}\left( \text{ord}_{p_1^{e_1}}(3), \text{ord}_{p_2^{e_2}}(3),\ldots, \text{ord}_{p_r^{e_r}}(3) \right) $$ won't be anything simple that depends only on magnitude of $n$. Instead, it depends strongly on how $n$ is factorized into its prime factors (as above formula suggests).

If we ignore the prime factorization of $n$, there aren't other pattern I can detect.
The only observation I have is:

It seems more than half of the time, $\tau_n$ is actually equal to $\lambda(n)$.

For $2 \le n \le 10^4$, there are $6666$ numbers relative prime to $3$. Among these numbers, about $58.2\%$ of them have $\tau_n = \lambda(n)$ and close to $89.7\%$ of them $\tau_n \ge \frac{\lambda(n)}{5}$.

If we increase the range, say to $2 \le n \le 10^5$, the statistics is roughly the same, $55.7\%$ for $\tau_n = \lambda(n)$ and $87.7\%$ for $\tau_n \ge \frac{\lambda(n)}{5}$.

Following is a table summarize this statistics for $n$ up to $10^4$.

$$\begin{array}{c:c:c} \hline s & \# \{ \lambda(n)/\tau_n = s\} & \# \{ n : \lambda/\tau_n \le s\}\\ \hline 1 & 3880 (58.21\%) & 3880 (58.21\%)\\ 2 & 1285 (19.28\%) & 5165 (77.48\%)\\ 3 & 369 ( 5.54\%) & 5534 (83.02\%)\\ 4 & 256 ( 3.84\%) & 5790 (86.86\%)\\ 5 & 190 ( 2.85\%) & 5980 (89.71\%)\\ 6-10 & 353 ( 5.30\%) & 6333 (95.00\%)\\ 11-15 & 165 ( 2.48\%) & 6498 (97.48\%)\\ 16-20 & 37 ( 0.56\%) & 6535 (98.03\%)\\ 21-25 & 27 ( 0.41\%) & 6562 (98.44\%)\\ 26-50 & 57 ( 0.86\%) & 6619 (99.29\%)\\ 51-75 & 19 ( 0.29\%) & 6638 (99.58\%)\\ 76-100 & 10 ( 0.15\%) & 6648 (99.73\%)\\ \hline \end{array}$$

Update 3

If you want to perform your own investigation, data of $\text{ord}_n(b)$ is available on OEIS:

In Mathematica, you can also compute $\lambda(n)$ and $\text{ord}_n(b)$ yourself using the commands Carmichael[n] and MultiplicativeOrder[b,n].

achille hui
  • 122,701
  • What is the big O of the carmicheal function? Also does it have to be divisible by the actual length or is it just an upper bound? – ruler501 Aug 23 '14 at 03:58
  • @ruler501 look at the average and typical value part of the wiki page. It is basically $O(n)$. – achille hui Aug 23 '14 at 04:08
  • So basically doesn't improve the bounds by more than a constant. Still interesting though. I think the average should be around the minimum times a constant but I'm not sure how to prove that – ruler501 Aug 23 '14 at 04:23
  • @ruler501 in this state, it doesn't improve that much. However, I suspect $\lambda(q)$ is not only an upper bound but the least upper bound when we vary $p$. I'm trying to find a proof of that. – achille hui Aug 23 '14 at 04:26
  • @rule501. Okay, $\lambda(n)$ is not the least upper bound if we fix $b$ and only allow to vary $p$. However, it is the least upper bound when we allow both $b$ and $q$ to vary. See update of answer (please note that I've switch to use $m/n$ instead of $p/q$ in the updated answer). – achille hui Aug 23 '14 at 07:24
  • So if we restricted $b$ to be say $3$ what kind of bound would we get? – ruler501 Aug 23 '14 at 14:19
  • @ruler501. I have no idea. However, numerical experiment suggests more than half of the time, the period $\tau\left(\frac{1}{n},3\right)$ is actually equal to $\lambda(n)$. See update of answer. – achille hui Aug 23 '14 at 19:06