Saturday 19 June 2021

Binary Odds and Evens


In my earlier post, titled Odds and Evens, I investigated what happened to decimal numbers when the odd-even recursive process was applied to them. In this process, the sum of a number's odd digits is added to the number and the sum of its even digits subtracted. In those numbers where the sum of the odd and even digits is equal, the number remains unchanged by this process and is termed an attractor, using the nomenclature that I developed. 112 is the first such number and any permutations of the digits of an attractor are also attractors. Thus 112 and 211 are also attractors. Less than 4% of numbers are of this types.

Most numbers are what I termed captives and the process leads them to either an attractor or a vortex. The steps in this process are termed its trajectory and as an example, let's use 5. It's trajectory is 5, 10, 11, 13, 17, 25, 28, 18 because the final number, 18, leads back to 11. The sequence of numbers 11, 13, 17, 25, 28, 18 constitutes a vortex from which there is no escape. On the other hand, 145 has a trajectory of 145, 147, 151, 158, 156 because 156 is an attractor and so no further change is possible. In my last post, titled Attractors, Vortices and Captives, I explored the odd-even decimal universe in more detail.


Figure 1: 150 is an attractor in binary but not in decimal

Once we use binary numbers however, a fundamental difference arises when the odd-even recursive process is applied. There are only 1's and 0's with the former being odd and thus are added while the latter, even though even, don't contribute. Thus there can be no vortices because return to an earlier number is not possible. The process always lead to increasingly bigger numbers and the process will never end. If we don't want the process to go on forever, then some intervention is necessary. One way to terminate the process is to stop when an equal number of 1's and O's is reached. If a number already has this balance then it is an attractor and remains unchanged. This is the approach followed in this post. At the end of this post, I'll suggest another approach.

This is a fundamentally different process. See Figure 1. If applied to decimal numbers, it would mean that a number like 201334 would be an attractor because it has three even digits and three odd digits, even though the sum of the odd digits is 7 and the sum of the even digits is 6. However, the process can be modified to accommodate our binary problem. We could say:

  1. For non-binary number systems, an attractor is defined as a number whose sum of even and odd digits is equal. The odd-even recursive process, as applied to non-binary numbers that are not attractors, is to add the sum of the odd digits and subtract the sum of the even digits so that a new number is generated. This process is repeated until an attractor is reached or the numbers enters a vortex, or endless loop of numbers.

  2. For the binary number system, an attractor is defined as a number with the same number of 1's and 0's. The odd-even recursive process, as applied to binary numbers that are not attractors, is to add the sum of the 1's so that a new number is generated. This process is repeated until an attractor is reached. Vortices are not possible in the binary number system.

Let's use 2149 as an example. As a binary number its trajectory would be:

100001100101, 100001101010, 100001101111, 100001110110

This number has a trajectory of length 3 because 100001110110 is an attractor, having an equal number of 1's and 0's. This attractor in decimal form is 2166. Some numbers take quite a few steps to reach an attractor. 243 is an example of such a number because it takes 59 steps to reach the attractor 527. I've created an algorithm to look at the first 30,000 numbers and I've discovered that the record is set by 15998 with a trajectory of length of 2228 steps, leading to a final number of 33231 (an attractor in the binary number system). Here is a permalink to that program.

In the range between 1 and 30000, attractors total 2353 or 7.84% while there are 27646 captives representing 92.16%.

I mentioned that I'd propose an alternative approach to the odd-even recursive process as applied to binary numbers. This approach involves treating 0's as -1 and 1's as simply 1's. Thus a binary number like 10010110 shown in Figure 1 would still be an attractor but vortices are now possible because of subtraction and these could draw in numbers in the same way that attractors do. The downside is that it treats 0's quite differently than in the higher bases. I'll try to investigate this approach in a future post.

No comments:

Post a Comment