About the probability of the occurrence of binary palindromes in the computer data

The aim of this work is to obtain expressions to calculate the probability of the occurrence of binary palindromes in a finite equally probable combination of zeros and ones. The classical definition of probability is applied in the calculation of the probability of the occurrence of binary palindromes. The key results of the study are presented in the form of two theorems. Furthermore, the consequences of these theorems and characteristic examples of calculation of the probability of the occurrence of the palindromes are considered. All formulated statements are supported by proofs. The main results of the work can be used when analyzing computer data stored in a binary code.


Introduction
In number theory, a palindrome is a symmetrical natural number. The term "palindrome" was introduced in the 17th century (from Greek πάλιν "back, again" and δρóμος "running, movement") [1]. Examples of the palindromes are numbers 1001, 13231, 456787654, etc. There is a simple algorithm, supposedly making it possible to obtain a palindrome from any integer number. In [2], the said "flipand-add" algorithm was used to calculate the number of steps to obtain a palindrome for numbers from 1 to 500. In [3], it was suggested that this algorithm will result in a palindrome for any integer number after a finite number of additions made. However, the mathematician Charles W. Trigg questions the validity of this assertion [3]. In fact, he found 251 numbers among under the number 10000 for which the said algorithm does not yield a palindrome after the first hundred additions. We should note that the smallest of these numbers is 196. In addition, the mathematician Dewey C. Duncan has shown that this algorithm does not always yield a palindrome in a binary system [3]. In particular, the binary number 10110 will never produce a palindrome. Besides numerical palindromes, there are also palindromic matrices, which are considered, for example, in the following publications [4], [5], [6]. [7] defined the number of palindromes of binary numeral system for even and odd numbers of digits. However, the authors have no knowledge of any publications providing the results of calculation of the probability of the occurrence of binary palindromes in finite equally probable combinations of zeros and ones.
The aim of this work is to obtain expressions to calculate the probability of the occurrence of binary palindromes in the finite equally probable combinations of zeros and ones. For this purpose, the first part of this work presents a theorem on the probability of the occurrence of n-digit binary palindromes in the finite equally probable n-digit combinations of zeros and ones. In the following, the author considers another theorem on the probability of the occurrence of the palindromes of less than n digits in the finite equally probable combinations of zeros and ones of n digits. It should be noted that the theoretical results of calculation of the probability of the occurrence of binary palindromes can be used when analyzing computer data stored in a binary code.
2. Probability of the occurrence of n-digit palindromes on an n-digit combination of zeros and ones of n digits Before formulating the results of calculating the probability of the occurrence of binary palindromes in equally probable combinations of zeros and ones, we will consider the following lemma. 2.1. Lemma 1. The number of all combinations of zeros and ones of n digits is equal to n 2 . Proof. In order to prove lemma 1, we will sequentially find the number of combinations of zeros and ones for 1, 2, 3, ..., n digits, respectively. For a 1-digit binary number, the number of combinations of zeros and ones is equal to . Lemma 1 is proved. Note that Lemma 1 makes it possible to find the number of all equally probable, incompatible, collectively exhaustive outcomes (occurrences of combinations of zeros and ones).
Let us give an example of using Lemma 1. Example 1. Let us find all possible combinations of 0 and 1 for 2 and 3 digits. In addition, we will find possible palindromes of 2 and 3 digits. According to lemma 1, the number of possible combinations for n=2 is equal to 4 2 2  . These combinations include: 00, 01, 10, 11. Two-digit number 11 is the only palindrome among the above combinations.
By analogy, according to lemma 1, the number of combinations for n=3 is equal to  Let us consider in more detail the problem of the random formation of m palindromes of n-digit within equally probable incompatible n-digit combinations of zeros and ones. We will consider the following as possible opposite event: we denote the occurrence of m palindromes of n-digit A and the absence of m palindromes in a random n-digit binary sequence of numbers A . Then the finite space of elementary events Ω={A, A }. It is known that the total number of terms of this family, i.e. the number of different random occurrences of n-digit binary number is equal to 2 n . In this case, the σ-algebra can be written in the form: F={A, A , Ω,  }. Here Ω is a certain event,  an impossible event. Thus, the axiom about the finite space being within the σ-algebra is true:  Let us assign to each of the events F A the value of probability measure P(A)=m/2 n . Here, the following axiom is true: . In addition, the axioms of probability are also true: the probability of a certain event P(Ω)=1; the probability of an impossible event P{  }=0 ; if the event A is an event ( F A ), then the opposite event A is also an event ( As a consequence, the probability of the occurrence of m palindromes of n-digit within the binary ndigit closed interval can be expressed as P(A)=m/2 n . The probability of the opposite event is Considering the last expressions, let P be the probability measure determined in F. As a result, we obtain the probabilistic space: (Ω, F, P). We formulate the calculation of the event A being the occurrence of m palindromes of n-digit within the n-digit binary closed segment as theorem 1.

Theorem 1.
The probability of the occurrence of a binary palindrome within equally probable, incompatible, collectively exhaustive n-digit combinations of zeros and ones is calculated as follows: 1. For an odd number of digits n, the probability of the event A is equal to: (1)

For an even number of digits n, the probability of the event A is equal to:
, n=2,4,6, … . (2) Proof: In order to find the probability of the event A, we will consider the case of odd and even numbers of digits of palindromes separately from each other.
First, let us consider the case of odd-digit palindromes. According to lemma 1, the number of all equally probable n-digit combinations of zeros and ones as incompatible, collectively exhaustive outcomes is equal to n 2 . In addition, the number of odd ndigit palindromes is equal to (for example, see [7]). Upon applying the expression to calculate the probability P(A)=m/ n 2 , we find that the probability of the occurrence of a palindrome within an equally probable binary odd n-digit combination of zeros and ones at . Secondly, let us consider the case of even-digit palindromes. According to lemma 1, the number of all equally probable n-digit combinations of zeros and ones is equal to 2 n . We assume that all these combinations are also incompatible and collectively exhaustive. In addition, the number of even ndigit palindromes is equal to (for example, see [7]). Upon applying the expression to calculate the probability P(A)=m/ n 2 , we find that the probability of the occurrence of m palindromes within an equally probable binary even n-digit combination of zeros and ones at . Theorem 1 is proved. Let us consider the consequences of theorem 1. Consequence 1.1. The highest probability of the occurrence of m binary n-digit palindromes is achieved for 2 and 3-digit palindromes and it is equal to 1/4. Proof: By applying the probability formula (2) at n=2 we obtain: . By applying the probability formula (1) at n=3 we obtain: . Similarly, by applying  (1) and (2) at any number of digits higher than 3, we obtain the probability of occurrence of a palindrome less than 1/4. Consequence 1.1 is proved.
2. An increase in both odd and even n digits leads to a decrease in the probability of the occurrence of m n-digit palindromes.
Proof: By applying the probability formula (1) to an odd n digit and at the next odd n+2 digit we obtain the fulfillment of the condition: ( 1)/2 ( ) 1/ 2   n PA > ( 3)/2 ( ) 1/ 2   n PA . By analogy, by applying formula (2) to an even n digit and the next even n+2 digit, we obtain the fulfillment of the condition: ( 2)/2 . Consequence 1.2 is proved. Consequence 1.3. At an infinite increase of both odd and even numbers of digits n, the probability of occurrence of m n-digit palindromes tends to zero.
Proof: Let us calculate the limit of a sequence with the general term written in the right part of formula (1) with the odd number of digits n tending to infinity. As a result, we obtain: ( 1)/2 ( ) lim 1/ 2 0    n n PA . We further calculate the limit of the sequence with the general term written in the right part of formula (2) with the even number of digits n tending to infinity. We obtain: ( 2)/2 Thus, at an infinite increase of both odd and even numbers of digits n, the probability of the occurrence of m binary n-digit palindromes tends to zero. Consequence 1.3 is proved.
Let us consider the following example. Example 2. We will calculate the probability of the occurrence of m binary n-digit palindromes in an equally probable n-digit combination of zeros and ones by using formulae (1) and (2). Let the number of digits of palindromes takes the following values n=2,3,4,5, 6,7,8,9,100,101,1000,1001. Table 2 contains the results of calculation of the required probability, obtained for the specified values of palindrome digits.

Probability of the occurrence of palindromes of less than n digits in an n-digit combination of zeros and ones.
Let us consider in detail the problem of a random occurrence of m palindromes of less than n digits within equally probable incompatible n-digit combinations of zeros and ones. We will consider the following as possible opposite event: we denote the occurrence of m palindromes of less than n digits B and the absence of m palindromes of less than n digits in a random binary n-digit sequence of numbers B . Then the finite space of elementary events Ω 1 ={B, B }. It is known that the total number of terms of this family, i.e. the number of different random occurrences of an n-digit binary number is also equal to 2 n . In this case, the σ-algebra can be written in the form: Here Ω 1 is a certain event,  is an impossible event. Here the axiom about the finite space belonging to the σalgebra becomes true: is true. As a consequence, the probability of the occurrence of m palindromes of less than n digits within the binary n-digit closed interval can be expressed as P(B)=k/2 n . Considering the last expressions, let P be the probability measure determined in F 1 . The probability of the opposite event is: P( B )=1-k/2 n . As a result, we obtain the probabilistic space: (Ω 1 , F 1 , P). We formulate the calculation of the event B being the occurrence of m palindromes of less than n digits within the n-digit binary closed segment as theorem 2. In order to find the probability of the event B, we will consider the case of odd and even numbers of digits of palindromes separately from each other.
First, let us consider the case of odd-digit palindromes. According to lemma 1, the number of all ndigit combinations of zeros and ones is equal to 2 n . We consider all these combinations to be equally probable, incompatible and collectively exhaustive. In addition, the number of odd-digit palindromes of n-i digits is equal to  [7]). Upon applying the expression to calculate the probability P(B)=m/2 n , we find that the probability of the occurrence of a binary odd-digit palindrome of n-i digits within an equally probable n-digit combination of zeros and ones is equal to Secondly, let us consider the case of even-digit palindromes. According to lemma 1, the number of all n-digit combinations of zeros and ones is equal to 2 n . We consider all these combinations to be equally probable, incompatible and collectively exhaustive. In addition, the number of even n-digit palindromes is equal to ( 2)/2 2    ni ni Q (for example, see [7]). Upon applying the expression to calculate the probability P(B)=k/2 n , we find that the probability of the occurrence of a binary evendigit palindrome of n-i digits within an equally probable n-digit combination of zeros and ones is equal to ( 2)/2 ( 2)/2 ( ) 2 / 2 1/ 2 . Theorem 2 is proved. Let us consider the consequences of theorem 2. Consequence 2.1. The highest probability of the occurrence of a binary palindrome of n-i digits in a equally probable incompatible n-digit combination of zeros and ones occurs for a 2-digit palindrome in the case of n=3, i=1, and for a 3-digit palindrome in the case of n=4, i=1. In both cases the probability is equal to 1/8.
Proof: Upon applying the probability formula (4) at n=3, i=1, we obtain: 8 1 2 1 Just as above, upon applying the probability formula (3) at n=4, i=1, we obtain: . Upon applying formulae (3) and (4) at all n>4, i  1, we obtain the probability of the occurrence of a palindrome of n-i digits within equally probable incompatible n-digit combinations of zeros and ones being less than 1/8. Consequence 2.1 is proved.
Consequence 2.2. A decrease in the number of digits of a palindrome of n-i digits with the number of equally probable incompatible n-digit combinations of zeros and ones being constant results in a decrease in the probability of occurrence both of odd-digit palindromes and even-digit palindromes.
Proof: Upon applying formula (3) to the odd number of digits n-i and the next smaller odd number of digits n-i-2, we obtain the fulfillment of the following condition: In a similar vein, in the case of even number of digits n-i and the next smaller even number of digits n-i-2, we obtain the fulfillment of the following condition from formula (4): ( 2)/2 ( ) 1/ 2   ni P В > ( 4)/2 ( ) 1/ 2   ni P В . Consequence 2.2 is proved. Consequence 2.3. At infinite increase of both odd and even number of digits in an n-digit combination of zeros and ones and constant finite number of digits of a palindrome of n-i digits, the probability of occurrence of this palindrome tends to zero.
Proof: Let us calculate the limit of a sequence with the general term recorded on the right side of the formula (3). In case of an odd number of digits n tending to infinity for the combination of zeros and ones, we obtain that i as well tends to infinity. As a result, we obtain: Next, we calculate the limit of a sequence with the general term recorded on the right side of the formula (4). In case of an odd number of digits n tending to infinity for a combination of zeros and ones, we obtain that i as well tends to infinity.
As a result, we obtain: Thus, at an infinite increase of both odd and even numbers of digits n of a combination of zeros and ones, the probability of the occurrence of a palindrome tends to zero. Consequence 2.3 is proved.
Let us give an example of the use of theorems 1-2. Example 3. We will calculate the probability of the occurrence of a binary palindrome of n-i digits in equally probable incompatible n-digit combinations of zeros and ones by using formulae (1)-(4). Let palindromes have the following numbers of digits n-i=2,3,4,5, 6,7,8,9, and of combinations of zeros and ones have the numbers of digits n=2,3,4,5, 6,7,8,9. Table 3 contains the results of calculation of the sought-for probability.
Dashed-out cell in the upper part of the table correspond to the numbers of digits of combinations of zeros and ones and palindromes, at which the sought-for probability does not exist. Indeed, in these cases, the numbers of digits of palindromes are higher than the numbers of digits of combinations of zeros and ones. In addition, in table 3 the sought-for probability becomes the highest at equality between the number of digits of combinations of zeroes and ones and the number of digits of  All probability values in table 3 below the diagonal ones have been calculated using expressions (3)-(4). It should be noted that the values of the sought-for probability in any odd and nearest right number of digits for palindromes, starting from a certain number of digits of combinations of zeros and ones, match each other. Thus, the higher the number of digits of a combination of zeros and ones, the more coincident pairs of probability values there is.

Conclusion
We have produced expressions for calculation of probability of the occurrence of binary palindromes in the finite equally probable combinations of zeros and ones. The key results have the form of two theorems. The first theorem is provided for calculating the probability of the occurrence of n-digit palindromes in the finite equally probable n-digit combinations of zeros and ones. The second theorem is a generalization of the first theorem. In this theorem, the probability of the occurrence of palindromes of less than n digits in the finite equally probable n-digit combinations of zeros and ones is calculated. The above theorems are accompanied by corresponding consequences. Like the theorems, the consequences also supported by proofs. The paper includes examples demonstrating the application of the obtained results to calculate the probability of the occurrence of binary palindromes. The results presented in the paper on calculating the probability of the occurrence of binary palindromes are intended to be used when analyzing computer data stored in a binary code.