0

I've been wondering about periods and solving for explicit relations of linear recurrences when working under a modulo. So like for example, The fibonacci sequence is defined as $F_0=0,F_1=1,F_n=F_{n-1}+F_{n-2}$. And one can find that $F_n=\frac{1}{\sqrt{5}}\left(\left(\frac{1+\sqrt{5}}{2}\right)^n-\left(\frac{1-\sqrt{5}}{2}\right)^n\right)$. However, if we were trying to find this recurrence in $\bmod 2$, this clearly wouldn't work as dividing by $2$ is most definitely not possible. If we instead tried to find the roots of the characteristic polynomial $x^2-x-1$ in$\bmod 2$, we would find that there are none, so this approach does not work as well. Moreover, from inspection the fibonacci sequence has period $3$ in $\bmod 2$, but if we were to express its explicit form as a sum of two powers we would not be able to as there are no numbers that have order $3$ in$\bmod 2$.

If instead, we tried to find an explicit formula for $F_n$ in$\bmod 3$, then we would need to find some $a$ such that $a^2\equiv 5\mod 3$. However, this clearly has no solution as $5$ is a nonquadratic residue in$\bmod 3$ (unless maybe we somehow introduce some type of imaginary number?). Also there are no elements with order $8$ in$\bmod 3$.

If we try to find a formula in$\bmod 5$, then we find that the solutions to $x^2-x-1$ has a double root of $x\equiv 3\bmod 5$, so we can determine that $F_n\equiv 4n\cdot 3^n\mod 5$. This seems to also match with the fact that $F_n$ has period $20$ in$\bmod 5$.

So, in the end we were able to find that we can explicitly find an equation for $F_n$ when taken modulo $p$ for some primes (particularly only $p=5$, but I'm sure there are others where $5$ is a quadratic residue). But I find it hard to believe that we can't find an explicit formula for other primes. Are there any other techniques to solve in these primes? Also this is only for the fibonacci sequence. What about for other recurrences, including higher order ones?

Alan Abraham
  • 5,142
  • 6
  • 20
  • $x^2-x-1=0$ has no solutions in the field of two elements, just as it has no solutions in the field of rationals, but it does have solutions in an extension field, in this case, the field of four elements. – Gerry Myerson Dec 10 '21 at 02:18
  • @GerryMyerson Sorry, I'm not very familiar with fields. I just took a introductory read over some concepts, and I agree that $x^2=x+1$ does have solutions, namely $A$ and $B$ (using the notation from https://en.wikipedia.org/wiki/Field_(mathematics)#Examples). And I see that $A^3=B^3=I$, which seems useful. But do we just say that $F_n\equiv A^n+B^n\mod 2$? This seems a little strange to me as $A$ and $B$ aren't actual numbers, and I can't think of anything that they would be. – Alan Abraham Dec 10 '21 at 03:42
  • We have $F_n=aA^n+bB^n$ for some elements $a,b$ of the field of four elements. We have to work out $a$ and $b$. When $n=0$, we get $0=a+b$; when $n=1$, we get $1=aA+bB$. So, $a=1/(A-B)$, $b=1/(B-A)$. We're in characteristic two, so $A-B=A+B$, and from your link, $A+B=1$, and $1/1=1$. So, $a=1$, and similarly we get $b=1$, so we wind up exactly where you said, $F_n=A^n+B^n$. As for whether or not $A$ and $B$ are actual numbers, they are just as actual as $\sqrt5$. In higher math, we don't ask what things are, just what they do, and we know what $A$ and $B$ do. – Gerry Myerson Dec 10 '21 at 06:54
  • $!\bmod 3,$ if we adjoin $,i,$ with $,i^2\equiv -1\equiv 5,$ then your formula using $\sqrt 5 \equiv i,$ still works, becoming $$ F_n \equiv -i,((-1-i)^n - (-1+i)^n)\pmod{!3}\qquad$$

    Rigorously, we adoin $i$ by working in $\Bbb Z_3[x]/(x^2+1)$ where $,i := \bar x$ is the image of $x$ in the quotient ring; equivalently we work with expressions of the form $,a+b, i,$ mod $,i^2+1,\ a,b\in\Bbb Z_3,,$ the same way we adjoin $i$ to $\Bbb R$.

    – Bill Dubuque Dec 10 '21 at 10:25
  • Our $,i,$ is an "actual number" - just like in the complex case, i.e. it is an element of a (quadratic) extension ring. Using such (algebraic) numbers allows us to simplify arithmetic in the base ring (e.g. by allowing us to split the quadratic into linear factors). – Bill Dubuque Dec 10 '21 at 10:25
  • @GerryMyerson Ok, thank you. If you could turn your comments into an answer, I can accept it. – Alan Abraham Dec 10 '21 at 19:43
  • @Bill, it occurs to me that I'm not sure how to solve something like $a_n\equiv a_{n-1}+a_{n-2}\bmod n$ for general $n$. If $n$ is prime then at worst we have to go to the field of $n^2$ elements to get roots of $x^2-x-1$, and if $n$ is squarefree then there's probably some way to apply the Chinese Remainder Theorem, but I don't see what to do when some $p^2$ divides $n$ and there isn't a field in sight. Can we work in ${\bf Z}_{p^2}/(x^2-5)$? – Gerry Myerson Dec 11 '21 at 05:08
  • 1
    @Gerry The formula below is universal so it can be specialized into any commutative ring $R$ containing a root $x$ of $,x^2-x-1,$ [if $R$ has no such root then adjoin one by extending it to $\bar R = R[x]/(x^2!-!x!-!1)$]

    $$\begin{align} F_n, =\ &\dfrac{x^n-\bar x^n}{x-\bar x}\ \ {\rm in}\ \ \Bbb Z[x]/(x^2!-!x!-!1),\ \ {\rm where}\ \ \bar x = 1-x\[.2em] =\ & \dfrac{x^n-(1!-!x)^n}{2x-1}\bmod x^2!-!x!-!1 \end{align}\qquad$$

    – Bill Dubuque Dec 11 '21 at 12:15
  • 1
    Above $\ f_n(x):= (x^n-\bar x^n)/(x-\bar x),$ denotes a polynomial $\in\Bbb Z[x],$ given by the exact quotient (but we can cancel $,2x-1,$ after specialization if it is regular in the target ring). When $,R=\Bbb Q[\sqrt{5}]$ then evaluating via $,x\to (1+\sqrt{5})/2,$ yields the classical formula in the OP. When $R = \Bbb Z_5,$ then evaluating $,x\to 3,$ works (must cancel here, before or after). When $R = \Bbb Z_3,$ then evaluating $,x\to -1-i,$ into $,\bar R = \Bbb Z_3[i],$ works, as I noted above. – Bill Dubuque Dec 11 '21 at 12:29
  • e.g. an Alpha computation of $,F_{20} = 6765!:,$ $\text{PolynomialRemainder}[\dfrac{x^{20}-(1-x)^{20}}{2x-1},\ x^2-x-1,\ x]$ done using the above formula. – Bill Dubuque Dec 11 '21 at 12:46
  • 1
    @Gerry Re: "universal" above. $,\bar R = R[x]/g(x)$ is a universal way of adjoining a root $x$ of $g$ to a ring $R$, in the sense that any other ring containing an image of $R$ and a root of $f$ is an image of $\bar R,,$ by the universal properties of polynomial and quotient rings; explicitly the hom maps $R$ to its image in the target and $x$ to the root there. This means that every true equality in $\bar R$ maps to a true equality in the image. – Bill Dubuque Dec 11 '21 at 17:02
  • In particular this is true for the above fibonacci formula $,F_n = f_n(x),,$ i.e. the formula remains true when we map into any ring containing a root of $,g(x)=x^2-x-1,,$ by evaluating $x$ at the root. – Bill Dubuque Dec 11 '21 at 17:02
  • 1
    @BillDubuque Would you like to compile your comments into an answer, so that I can accept it? – Alan Abraham Dec 11 '21 at 21:44

0 Answers0