Recently, I had the pleasure of finding out that
$$13^2=169\quad\text{and}\quad 31^2=961.$$
It had me wondering . . .
The Question:
What pairs of distinct natural numbers $r,s$ have decimal expansions $r=\overline{a_1\dots a_n}$ and $s=\overline{a_n\dots a_1}$ such that $$(\overline{a_1\dots a_n})^2=\overline{x_1\dots x_m}\quad\text{and}\quad (\overline{a_n\dots a_1})^2=\overline{x_m\dots x_1}?$$
Clarification: I'm asking for all of them; that is, is there a formula or something?
Thoughts:
I have no idea.
Single digit numbers won't do.
According to Approach0, this is new to MSE. The closest I could find on the OEIS is this.
Other pairs include $12$ & $21$ and $102$ & $201$.
This is the sort of thing a programme could search for. I have a rough idea of how I might write one, but it would be very inefficient. Here is the gist:
DecimalExpansionAsList:=function(n)
return decimal expansion of n as a list somehow;
end;
ListToNumber:=function(L) # L is a list of natural numbers less that 10
local m; # m length of L
return (10^m)*L[m]+(10^(m-1))*L[m-1]+ (somehow continue like this)
end;
NumberPairs:=[];
for i in [0..9] do
for j in [0..9] do
for k in [0..9] do
n:=ListToNumber([i,j,k]);
m:=ListToNumber([k,j,i]);
if DecimalExpansionAsList(n^2)=(Swap order of DecimalExpansionAsList(m^2) somehow) then
AddSet(NumberPairs, [n,m]);
fi;
od;
od;
od;
Print(NumberPairs);
I would be surprised if the examples listed above are the only ones.
Further Context:
I came up with this question myself. I don't think I could answer it myself.
Please help :)
Approach0 only works if you can guess a formula that must occur in the question. In this case it is possible to say that $961$ is the square of $31$ without actually writing $31^2 = 961$. So it did not find the question Generalizing $\,r(n^2) = r(n)^2,\,$ for $\,r(n) := $ reverse the digits of $n$, which is very close to your question.
This answer to that other question relates your question to a theorem about polynomials. The reciprocal of a polynomial $p(x)$ can be constructed by reversing the coefficients of $p(x)$; that is, if $p(x)$ has degree $n$, we swap the coefficients of $x^n$ and $1$, swap the coefficients of $x^{n-1}$ and $x$, and so forth.
Let's use a superscript asterisk to denote reversing coefficients; that is, the reciprocal of the polynomial $p(x)$ is written $p^*(x)$.
The linked answer points out that if $f(x)$, $g(x)$, and $h(x)$ are polynomials such that $f(x)g(x) = h(x)$, then $f^*(x)g^*(x) = h^*(x)$. In the case where $g$ is the same as $f$, this means that $$ h(x) = (f(x))^2 \implies h^*(x) = (f^*(x))^2, $$
that is, the reversal of the square of a polynomial is the square of the reversal of the same polynomial; therefore, if all the coefficients of $f(x)$ and $h(x)$ are positive single-digit numbers (or, for coefficients other than the first or last, possibly zero), and $f(x)$ is not a palindromic polynomial (that is, $f(x) \neq f^*(x)$), then $f(10)$ and $f^*(10)$ form one of the pairs you are looking for.
The reason why the coefficients of $f(x)$ must be positive single-digit numbers or zero is so that $f(10)$ will be the standard expansion of the value of a base-ten numeric representation:
$$ a_n 10^n + a_{n-1} 10^{n-1} + \cdots + a_2 10^2 + a_1 10^1 + a_0. $$
The reason for the restriction on the coefficients of $h(x)$ is that if the coefficient of $x^k$ in $h(x)$ has two digits or more, then some of the digits of that coefficient will carry into places to the left of the $10^k$'s place when $h(10)$ is written in base ten. For example, let $f(x) = 2x^2 + 3$. Then $f^*(x) = 3x^2 + 2$, \begin{align} (f(x))^2 &= 4x^4 + 12x^2 + 9, \\ (f^*(x))^2 &= 9x^4 + 12x^2 + 4, \end{align} which are reciprocal polynomials, but when we plug in $x=10$ we have\begin{align} (f(10))^2 &= (203)^2 = 41209, \\ (f^*(10))^2 &= (302)^2 = 91204, \end{align} and the squares are not reversals of each other because the $1$ from the coefficient $12$ went into the thousands place in both cases, breaking the symmetry.
The restriction on the coefficients of $h(x)$ means that none of the coefficients of $f(x)$ can be greater than $3$, since $(a_k x^k)^2 = a_k^2 x^{2k}$. If there is a coefficient $3$ in $f(x)$, no other coefficient can be greater than $1$, since $(3 x^k + a_m x^m)^2$ produces the term $6a_m x^{k+m}$. But it seems you can have any number of non-zero coefficients as long as you insert zero coefficients between them in such a way that you never have too many pairs of coefficients in $f(x)$ contributing to the same coefficient in $h(x)$. It seems difficult to come up with a simple formula to generate all possibilities.