1

I tinkered with this method to calculate the remainder of a division you can see the examples, and the questions I ask myself are:

Question 1:

In what case is this method better than other methods for finding the remainder of the division.

Question 2:

Could we find a way to use it for all the examples(the best polynomials to choose to make calculating the remainder easier)?

Example 1: What is the remainder when $10^{124}-5$ is divided by $33$?

We have $(10^{124}–5)/33=(10^{124}–5)/(3*10+3)$

I set $x=10$ so I have $P1/P2=(x^{124}–5)/(3x+3)$ with $P1=(x^{124}–5)$ and $P2=(3x+3)$

Using the Euclidean division of polynomials, to divide by a polynomial of degree $1$ $P2$, simply interpolate at the root of the divisor, here $x = -1$ because $P2(-1)=0$.

We know that $P1=qP2+r$ with $r$ of degree zero.

And that $r=P1(-1)=(-1^{124}–5)=-4$ which equals $29$ mod $33$.

Example 2: What is the remainder when $1009^{12}+1$ is divided by $2017$?

I set $x=1009$ so I have $P1/P2=(x^{12}+1)/2017=(x^{12}+1)/(2x - 1)$ with $P1=(x^{12}+1)$ and $P2=(2x - 1)$

Using the Euclidean division of polynomials, to divide by a polynomial of degree $1$ $P2$, simply interpolate at the root of the divisor, here $x = 1/2$ because $P2(1/2)=0$.

We know that $P1=qP2+r$ with r of degree zero.

And that $r=P1(1/2)=(2^{12}+1)/2^{12}=4097/4096$

So $4096=4097r$ mod $2017$ with $r < 2017$ With an excel spreadsheet we find $r=489$.

Example 3: What is the remainder when $4^{29}$ is divided by $63$?

We have $(4^{29})/63 = (4^{29})/(4^3–1)$.

I set $x = 4$, so I have $P1/P2 = (x^{29})/(x^3–1)$with $P1 = x^{29}$ and P2 = $(x^3–1)$.

By using Euclidean division of polynomials:

$r=x^2=4^2=16$ , the remainder is $16$ mod $63$.

Or I can of course reduce large numbers in the form $P1=x^{29}=x^2*X^{27}=16X^{27}$ and in the divisor I replace $x^3=X$ so I directly have $r=P1(1 )=16$ with $P2=X-1$ and $P2(1)=0$.

z.10.46
  • 27
  • 5
  • 1
    The usual method is just iterated squaring...is this faster than that? – lulu Jan 06 '24 at 13:20
  • Your examples aren't great. $33=3\times 11$ and it's easy to work modulo those small primes. Similarly, $63=3^2\times 7$. – lulu Jan 06 '24 at 13:21
  • Yes but here with this method even if we have large numbers we can transform them into any polynomial form to find the remainder easily. In short, you just need to find the best possible polynomial choices to find the rest easily. – z.10.46 Jan 06 '24 at 13:31
  • 2
    Well..you should seek an example for which your method actually beats easier ones. And, like I mentioned, iterated squaring is very easy. Pencil and paper...$\pmod {2017}$ we have ${1009^{(2^n)}}={1009,1513,1891,1757}$ and $1009^{12}=1009^4\times 1009^8=1891\times 1757=488$. – lulu Jan 06 '24 at 13:36
  • "choosing" the right polynomial for some huge modulus will, generally, be extremely difficult, but of course your modulus might be handed to you as a value of a polynomial. Perhaps in those cases there is an advantage. – lulu Jan 06 '24 at 13:38
  • Yes, especially when you divide by a polynomial of degree 1, you already know what the remainder of the division is, it can reduce a lot of calculations.. – z.10.46 Jan 06 '24 at 13:41
  • As the exponent $12$ is even, it might be easier to work with $(-1009)^{12}+1 \equiv 1008^{12}+1 \pmod {2017}$ instead. – Geoffrey Trang Jan 06 '24 at 17:49
  • In fact, I want to use this method to quickly test whether a number in the form $2^n -1$ is prime or not for an odd integer $n$.

    Simply set ($2^n -1)/(2k-1)$ or ($2^n -1)/(2k+1)$ with $1<k<\sqrt{n}$ $(2^n -1)/(2k-1)=(x^n -1)/(2k-x/2)$ or $(2^n -1)/(2k+1)=(x^n -1)/(2k+x/2)$, so $r=(4k)^n-1$ or $r=(-4k)^n-1$ in any case, I am trying to express the remainder in terms of $k$ and show that for a given $n$, the remainder will never be zero $\mod k$.

    – z.10.46 Jan 06 '24 at 18:38

1 Answers1

1

It is quite well-known that many integer remainders are often easily computed as special cases of polynomial remainders, e.g. the ubiquitous application of the Polynomial Remainder Theorem: $\,f(x)\equiv f(a)\pmod{\!x\!-\!a},\,$ as you do in your first example with $a=-1$, and your third example with $\,a=1,\,$ i.e. $\,f(n)\equiv f(1)\pmod{n\!-\!1},\,$ for $\,n=4^3.\,$ In your second example with $\rm\color{#c00}{nonmonic}$ divisor $\,\color{#c00}2x-1$ we can use a fractional Polynomial Remainder Theorem

$$f(n)\equiv f(a/b)\!\!\pmod{bn\!-\!a}\ \ \ {\bf if}\ \ \ (a,b)=1$$

or, equivalently, we can use a nonmonic Polynomial Division Algorithm. Such polynomial modular reductions often prove handy when computing gcds, e.g. see here and here.

Note $ $ (Lagrange) Polynomial interpolation is a special case of CRT = Chinese Remainder Theorem and these methods are also well-known and frequently applied when computing remainders and related objects, e.g. see here.

Bill Dubuque
  • 272,048