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?
Generalizing $\,r(n^2) = r(n)^2,\,$ for $\,r(n) := $ reverse the digits of $n$
decimal-expansionelementary-number-theorypolynomialssquare-numbers
Related Solutions
Your problem sets out to solve the following system of modular equations:
x1 + 2*x2 + 2*x3 + 2*x4 + 2*x5 + x6 + x7 = A (mod 100)
x4 + x5 = B (mod 10)
x2 + x3 = C (mod 10)
The first equivalence comes from steps 1-3 above, the second from step 4 and the third from step 5. The basic math that you need to solve a system of equivalences is the Chinese Remainder Theorem.
This system will not have a unique solution. To see how redundant it is, count the possibilities for the sequence (x1,x2,x3,x4,x5,x6,x7)
and (C,B,A)
separately. For the former, x1,x6,x7
are interchangeable as are x4,x5
and x2,x3
, so we count them separately. There are (45+3-1 choose 3)
ways to choose x1,x6,x7
each between 01
and 45
(remember to choose with repetition), and (45+2-1 choose 2)
ways to choose each of the other pairs. This gives a total of
(47 choose 3)*(46 choose 2)^2 = 16 782 525
ways of choosing the x
s. For the 4-digit sequence, there are 10 000
possibilities. The number above is far larger, so certainly there is a lot of repetition.
If you want to pin down just one x
sequence that yields a given CBA
sequence, then you can simplify the problem by choosing arbitrary values for x6,x7,x5,x3
and then using the CRT to solve for x1,x4,x2
(which may or may not exist).
For example, suppose you take
x3 = 19, x5 = 22, x6 = 31, x7 = 13
Then you solve for the remaining x
s by solving this system
x4 + 22 = 3 (mod 10)
x2 + 19 = 4 (mod 10)
x1 + 2*x2 + 38 + 2*x4 + 44 + 31 + 13 = 82 (mod 100)
The first two equations are easy, though the solutions are not unique
x4 = 1 (mod 10) => x4 = 1, 11, 21, 31, or 41
x2 = 5 (mod 10) => x2 = 5, 15, 25, 35, or 45
Adding in the final equation to solve for x1
and pin down x2,x4
gives
x1 + 2*(x2 + x4) = 56 (mod 100)
which has many solutions, among them x1 = 4, x2 = 5, x4 = 21
, but also x1 = 44, x2 = 5, x4 = 1
as well as many others.
So, you are looking for a way to flip the number about the decimal point in whatever base. Here is the function which will do it
$$f(x)=\sum_{n=0}^{\infty} 10^{-n-1} \left(\left\lfloor\frac{x}{10^n}\right\rfloor \mod 10\right)+\sum_{n=1}^{\infty} 10^{n-1} \left(\left\lfloor 10^nx\right\rfloor \mod 10\right)$$
which is just a compact form of an algorithm. This is basically starting from the decimal point, first going to the left the digits are flipped. Then the second sum starts from the decimal point and going to the right flips the digits.
For whatever base, just replace all of the 10's with whatever base you want. This will work fine when the number (in whatever base) has a terminated expansion on both sides of the decimal point meaning both sums are finite. For irrational numbers for example, the second sum won't converge and the function isn't defined at all so don't use this to flip the digits of $\sqrt{2}$ because it can't be done. Another way to say that is the algorithm won't terminate in finite time (and we don't have infinite memory) because we don't know the "last" digit of $\sqrt{2}$ in base 10 for example. And even for some rational numbers this function doesn't make sense. For example you can't flip the decimal expansion of 1/3 in base 10 because it doesn't terminate in base 10.
Best Answer
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
$\ \ r(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 $\,r(fg)\, =\, r(f)r(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 (so no carries occur; in the OP squaring case such integers are sometimes called skinny).
Note that reversing twice yields the original polynomial when the reverse has the same degree $(\!\!\iff\! f(0)\neq 0),\,$ i.e. in this case reversing is an involution or reflection $\,r^2 f = f\,$ since we have $r(r(f(x)) = x^n r(f(x^{-1})) = x^n ((x^{-1})^nf((x^{-1})^{-1}) = f(x).\,$ In particular $\,f(0)\neq 0\,$ is true when $\,f = rg\,$ is a reversal, so $\,r^2(rg) = rg,\,$ i.e. $\,r^3g = rg\,$ for all $\,g$.
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).