Proof

If \(D\) is even, then the image of \(f_{D}\) has \(\frac{19^{\frac{D}{2}}+1}{2}\) elements.

If \(D\) is odd, then the image of \(f_{D}\) has \(\frac{19^{\frac{D-1}{2}}+1}{2}\) elements.


Let us see two examples. If \(D=4\) and \(n=abcd\), with \(a\geq d\) (it is sufficient to consider these cases because \(f_{D}\) computes the difference between the biggest and the smallest number within the pair comprised by \(n\) and \(i_{D}(n)\)), then \[f_{4}(n)=\left|[10^{3} - 1](a-d) + [10^{2} - 10](b-c)\right|.\]

Therefore:

Hence, the image of \(f_{4}\) contains \(10 + 9\times 19 = 1 + 9 + 9\times 19 = 181\) elements. Note also that \(1 + 9 + 9\times 19 = \frac{19^{2} + 1}{2}\).

If \(D=6\) and \(n=abcdef\) with \(a\geq f\), then \[f_{6}(n) = \left|[10^{5} - 1](a-f) + [10^{4} - 10](b-e) + [10^{3} - 10^{2} ](c-d)\right|\] and

Consequently, the cardinal of the image of \(f_{D}\) is \[10 + 9\times 19 + 9\times 19\times 19 = 1 + 9 + 9\times 19+ 9\times 19^{2} = 3430.\] And one has \(1 + 9 + 9\times 19 + 9\times 19^{2} = 1 + 9\, (1 + 19 + 19^{2}) = \frac{19^{3} + 1}{2}\).

Let us generalize these arguments to the set \(N_{D}\). Since \[f_{D}(x)=\left|x_{D-1}x_{D-2} ... x_{1}x_{0} - x_{0}x_{1} ... x_{D-2}x_{D-1}\right|,\] when \(D\) is even we obtain \[f_{D}(x)=\left|(10^{D-1} - 1)(x_{D-1} - x_{0})+ (10^{D-2} - 10)(x_{D-2} - x_{1})+ ... +\left (10^{\frac{D}{2}} - 10^{\frac{D}{2}-1}\right)\left(x_{\frac{D}{2}} - x_{\frac{D}{2}-1}\right)\right|\] and, when \(D\) is odd, \[f_{D}(x)=\left|(10^{D-1} - 1)(x_{D-1} - x_{0})+ (10^{D-2} - 10)(x_{D-2} - x_{1})+ ... + \left(10^{\frac{D+1}{2}} - 10^{\frac{D-3}{2}}\right)\left(x_{\frac{D+1}{2}} - x_{\frac{D-3}{2}}\right)\right|.\]

Hence, in the image of \(f\) we only find the nonnegative integers that can be written in the form \[(10^{D-1} - 1)z_{1} + (10^{D-2} - 10)z_{2} +...+\left (10^{\frac{D}{2}} - 10^{\frac{D}{2}-1}\right)z_{\frac{D}{2}} \mbox{ if }D \mbox{ is even}\] \[(10^{D-1} - 1)z_{1} + (10^{D-2} - 10)z_{2} +...+ \left(10^{\frac{D+1}{2}} - 10^{\frac{D-3}{2}}\right)z_{\frac{D-1}{2}} \mbox{ if }D \mbox{ is odd,}\] where \(0 \leq z_{1} \leq 9\) and \(-9 \leq z_{j} \leq 9\) for \(j>1\).

Subject to these conditions only, we would obtain \(10\times 19^{\frac{D}{2}-1}\) numbers when \(D\) is even. Actually, the \(z_{i}´s\) are not independent from each other. Let us see the case where \(D\) is even (the other case is analogous). If there is some \(z_{j} \neq 0\) and \(k = \mbox{minimum }\{0 \leq i \leq \frac{D}{2}: z_{i} \neq 0\}\), then \(1 \leq z_{k} \leq 9\) and \(-9 \leq z_{i} \leq 9\) for \( i>k\). Analyzing the possibilities for each value of \(k\), we conclude that among the \(10^{D}\) natural numbers with \(D\) digits, only \[10+9\times 19+9\times 19^{2}+...+9\times 10^{\frac{D}{2}-1}=\frac{19^{\frac{D}{2}}+1}{2}\] of them are in the image of \(f_{D}\).

By a similar argument, we deduce that, for \(D\) odd, the cardinal of that image is \(\frac{19^{\frac{D-1}{2}} + 1}{2}\).

Notice that the frequency of numbers in the image of \(f_{D}\) has limit \(0\) when \(D\) goes to infinity, since \[\frac{19^\frac{D}{2} + 1}{ 2\times 10^{D}}< \left(\frac{1}{5}\right)^{\frac{D}{2}}.\]