Non-Recursive Base Conversion Using a Deterministic Markov Process ()
1. Introduction
Mathematically, the base or radix, b is the building block of a number. A digit of a number is maximally b − 1. For example, the largest digit in base ten is nine. The subject matter of this paper is about converting a number from one base system to another base system and revealing the coupling between base conversion and a Markov process.
To discuss the conditions that couple non-recursive base conversion to a deterministic Markov process, we need to break down the concepts involved:
Non-Recursive Base Conversion: This refers to the process of converting a number from one base to another without using recursion. The conversion process involves a series of steps that can be explicitly listed and executed sequentially, such as dividing the number by the new base and taking the remainder to form the digits of the new base.
Deterministic Markov Process: A Markov process is a stochastic process where the probability of transitioning to any future state depends only on the current state and not on the sequence of events that preceded it. A deterministic Markov process implies that the transitions between states are determined by a fixed rule without any randomness. Essentially, the deterministic Markov process presented in this paper has transition probabilities equal to 1.
The theorem presented in this paper is not to be confused with the Base Conversion Theorem by Matula [1]. The Base Conversion Theorem stipulates the conditions under which base conversions are one-to-one and/or onto. The theorem presented in this paper provides a specific method to produce non-recursive base conversion for positive integers and decimal numbers that are consistent with deterministic Markov processes.
1.1. The Markov Base Conversion Theorem
The base conversion of a number has historically been a recursive process that depends on the dividends and remainders from Euclidean division or the multiplication of real numbers [2] [3] [4]. We derive a process that easily converts a number from base ten to another base without recursion. The theorem is fundamentally based on the intuitive process of isolating digits in a base ten or decimal number that are separated by powers of ten and therefore are distinctly represented in the number. The process that separates the base ten elements from the number simply isolates the digits of the decimal number. The derived process does not depend on the remainders from division. By generating the process to convert between decimal and an arbitrary base, we derive the theorem of deterministic Markov base conversion. The theorem specifies base conversion between an N-digit positive decimal number less than one and any other base. While base conversion readily extends to negative and floating-point numbers [5] [6] [7] [8], we will not discuss that extension in this paper. An essential component of the theorem is the use of the floor function and the geometric series [9] [10]. We also show that a deterministic Markov base conversion is twice as efficient, mathematically, as typical base conversion methods, such as iterative or non-recursive methods.
1.2. A Markov Chain or Markov Process
A Markov chain or Markov process is a stochastic model describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event. Informally, this may be thought of as, “What happens next depends only on the state of affairs now.”
A deterministic Markov process is generally non-recursive as it typically involves state transitions governed by deterministic rules or functions, which can be implemented iteratively without the need for recursive calls.
Recursive base conversion is a clear and concise method for converting numbers between bases, though it may not always be the most efficient. For small to moderately sized numbers, it provides a readable and maintainable solution. For larger numbers, an iterative approach might be more suitable to avoid potential performance and memory issues.
Coupling non-recursive base conversion to a deterministic Markov process involves defining states that represent each stage of the conversion, establishing deterministic transition rules that depend solely on the current state, and ensuring the process terminates in a final state representing the converted number. This approach leverages the deterministic nature of both the base conversion algorithm and the Markov process framework to achieve the desired coupling.
A deterministic Markov process describes state transitions where the next state is determined solely by the current state.
It can be implemented either iteratively or recursively. The choice of implementation depends on the specific requirements and constraints of the problem at hand.
An iterative implementation is generally more memory-efficient and straightforward, while a recursive implementation might be more intuitive for certain problems but risks stack overflow for large numbers of state transitions.
2. Recursive Base Conversion
We want to consider two cases: 1) base conversion for a positive integer and 2) base conversion for a positive number less than one. In case one, we want to show that a recursive process that retains the remainders from Euclidean division achieves a conversion between base ten and any other base.
Consider a positive N-digit base-ten integer x. We can write it as
,(1)
where
are the digits of x in the base b > 1. Observe that if you divide
by b, by Euclidean division you get
(2)
For some positive integers
and
. You can then recursively divide
by b (note that this will require only a finite number of steps), obtaining
(3)
with
. Therefore,
as required.
Now let us examine case two. Consider a positive N-digit decimal number less than one. We can write it as
.(4)
where
are the digits of x in the base b > 1. Observe that if you multiply
by b, you get
.(5)
and if you multiply
by b you get
,(6)
where
and
are positive integers. If we multiply by
, we get
(7)
We can then recursively multiply by
{N operations}
When the highest version of x is zero, we have
as required.
3. Non-Recursive Base Conversion
We now present a theorem that derives non-recursive base conversion for a positive integer and a positive number less than one, respectively, with the result equivalent to a deterministic Markov process. The theorem proves that the Markov process is twice as efficient as standard base conversion.
Theorem I.
If
, for
,
and
, then
,
where
≡ the greatest integer function (i.e. floor function) rand
.
Proof. First, evaluate
Since the floor function is distributive,
Because of the condition:
, only the second term within the first sum survives:
Only the
term in the first sum survives {because of the geometric series} while the complete sum becomes:
⊡
Corollary:
Observe that this result is easily invertible:
Example (1): First, convert 407 to base 4 using the standard recursion approach:
Therefore, 407 = 12,113four and this conversion required 10 (i.e. N) operations, which includes the remainder operations.
Now, use the non-recursive Markov approach:
Therefore, 407 = 12,113four and this conversion required 6 [i.e. (N/2 + 1) operations.]
Example (2):
Convert 0.390625 to base 2 using the standard recursion approach:
Therefore,
Now, use the non-recursive Markov approach, with x = 0.390625, b = 2 and N = 6.
Thus, we get the same result:
4. Conclusion
Coupling non-recursive base conversion to a deterministic Markov process involves defining states that represent each stage of the conversion, establishing deterministic transition rules that depend solely on the current state, and ensuring the process terminates in a final state representing the converted number. This approach leverages the deterministic nature of both the base conversion algorithm and the Markov process framework to achieve the desired coupling. With the presentation of Theorem I, in this paper, we prove that any recursive base conversion process can be converted into a Markov process with unit transition probabilities and the Markov process is twice as efficient as the standard recursive approach to base conversion.