# Generalizing $\,r(n^2) = r(n)^2,\,$ for $\,r(n) :=$ reverse the digits of $n$

I'm assuming this theorem was found by someone else before, but I found this relationship between square numbers of 3 digits or less. The theorem is this: If you reverse the digits in a square number, then the result will also be a square number. Take the square 961. It is 31 squared, and if you reverse the digits you will get 169, which is also a square number. Plus, 31 and 13(the roots of these reversed squares) are also reverses of eachother. The problem is this breaks with 4 or more digits. If I take the square 1024 and reverse the digits, I get 4201, which is not a square. How can I expand this theorem to fit 4 or more digits?

• $15^2=225$. $522$ is not a square number. – player3236 Sep 17 at 18:36
• Also $14^2,16^2,17^2,...$ – user208649 Sep 17 at 18:49
• It can’t be true because squares never end in the digits $2,3,7,8$ but it’s easy to find squares that have those as their starting digits, and hence after reversing digits you don’t get a square. – user208649 Sep 17 at 18:51
• This is only true if the digits of the square root are small; they need to both be $\le 3$ and their product needs to be $\le 4$. – Qiaochu Yuan Sep 17 at 19:08
• I added an answer which shows where it comes from (and where it does hold true without constraint, i.e. for polynomials). – Bill Dubuque Sep 17 at 19:20

Congratulations, you have essentially discovered an interesting property of polynomials - as (partially) manifested in their evaluations (here radix $$10$$ polynomials). Namely, reversing the coefficients of a polynomial is a multiplicative operation.

Let $$\,f = a_n x^n +\cdots a_1 x + a_0\,$$ be a polynomial in $$x.\,$$ Reversing its coefficients yields

$$\quad\ \ \bar f = a_0 x^n + \cdots a_{n-1}x + a_n = x^n f(x^{-1}),\$$ the reverse (or reciprocal) of $$\,f.$$

It is easy to show $$\overline{fg}\, =\, \bar f\bar g,\,$$ i.e. polynomial reversal is multiplicative. For example

\qquad \begin{align} (x+2)\ (x+3)\, &=\ \ x^2+5x+6\, \overset{\large x\, =\, 10}\Longrightarrow\, 12\cdot 13\, =\, 156\\ \overset{\rm reverse}\Longrightarrow (2x+1)(3x+1)\, &= 6x^2+5x+1\ \ \Longrightarrow\,\ \ 21\cdot 31\, =\, 651 \end{align}

Your examples are special cases when the product is a square (of polynomials of degree $$\le 3),\,$$ but from above we see it generalizes to arbitrary degree polynomials. However, for the polynomials to yield integer reversals when evaluated at the radix $$\,x=10\,$$ it is necessary that all polynomials (including the product) have nonnegative coefficients less than the radix.

Remark  Generally the evaluation map helps relate (ring-theoretic) properties of polynomials to properties of their evaluations. For example, in some contexts we can deduce that if a polynomial takes a value with few factors then the polynomial must have few factors too (this is often used in contest problems since it is not as well-known as it should be).

One can push this idea to the hilt to obtain a simple algorithm for polynomial factorization using factorization of its integer values and Lagrange interpolation (using ideas going back to Bernoulli, Schubert and Kronecker).

• So what you are saying is that this will work for non-square real numbers? Does it work with coefficients greater than 3? – Trevor Mershon Sep 17 at 19:23
• @Trevor Square the general degreed trinomial polynomial with undetermined coefs, then find the values of the coefs that are small enough that all the polynomials (including product) have coefs less that the radix [else carries may happen which make the reversal no longer hold for integer (vs. polynomials)]. Note that the same works for any products, not only squares, as the example above shows (reversing $12\cdot 13)\ \$ – Bill Dubuque Sep 17 at 19:29
• That makes sense. Is there a way to do this if one or multiple of the coefficients is larger than the radix? – Trevor Mershon Sep 17 at 19:31
• @Trevor There may be some special (paramterized) classes that one can work out nicely, but it's probably not tractable to account for the effect of carries in general. – Bill Dubuque Sep 17 at 19:32
• Alright, thanks. I realized I can just make the radix larger so its larger than all the coeffs. For the equation (2x+9)(x+2) a radix of 10 didn't work, but a radix of 20 did. – Trevor Mershon Sep 17 at 19:34

Hint: If a 3-digit square equals $$(10x+y)^2 (1 \leq x,y \leq 9)$$, what are the conditions on $$x,y$$ for the 3 digits in reverse order to form a square? Can you extend this to, for example, a 5-digit square equalling $$(100x+y)^2$$?

The point is that $$(10a+b)^2=100a^2+20ab+b^2$$. The reversal will work as long as $$a^2,2ab,b^2$$ are all less than $$10$$ so there is no carry. If you try to go to four digit squares you need $$a^2$$ or $$2ab$$ to carry, which will make the reversal fail.

If you go to three digit square roots, we have $$(100a^2+10b^2+c)^2=10000a^4+2000ab+100(b^2+2ac)+20bc+c^2$$. To make the reversal work, you need no carries here, so all the digits need to be small.