Non-Recursive Base Conversion Using a Deterministic Markov Process

Abstract

We prove that non-recursive base conversion can always be implemented by using a deterministic Markov process. Our paper discusses the pros and cons of recursive and non-recursive methods, in general. And we include a comparison between non-recursion and a deterministic Markov process, proving that the Markov process is twice as efficient.

Share and Cite:

Houston, L. (2024) Non-Recursive Base Conversion Using a Deterministic Markov Process. Journal of Applied Mathematics and Physics, 12, 2112-2118. doi: 10.4236/jamp.2024.126129.

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

x= i=1 N a i b i1 ,(1)

where { a i } are the digits of x in the base b > 1. Observe that if you divide x= x ( 1 ) by b, by Euclidean division you get

x ( 1 ) = r 1 +b x ( 2 ) (2)

For some positive integers x ( 2 ) < x ( 1 ) and r 1 <b . You can then recursively divide x ( 2 ) by b (note that this will require only a finite number of steps), obtaining

x= r 1 +b( r 2 +b( +b( r N ) ) ) (3)

with 0 r 1 <b . Therefore, a i = r i as required.

Now let us examine case two. Consider a positive N-digit decimal number less than one. We can write it as

x= i=1 N a i b i1N .(4)

where { a i } are the digits of x in the base b > 1. Observe that if you multiply x= x ( 1 ) by b, you get

b x ( 1 ) = x ( 2 ) + q N .(5)

and if you multiply x= x ( 2 ) by b you get

b x ( 2 ) = x ( 3 ) + q N1 ,(6)

where q N and q N1 are positive integers. If we multiply by b 1 , we get

x ( 1 ) = b 1 x ( 2 ) + b 1 q N (7)

We can then recursively multiply by b 1

x ( 1 ) = b 1 ( b 1 x ( 3 ) ++ b 1 q N1 )+ b 1 q N

x ( 1 ) = b 1 ( b 1 ( b 1 x ( 4 ) + b 1 q N2 )+ b 1 q N1 )+ b 1 q N {N operations}

When the highest version of x is zero, we have a i = q i 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 x= k=1 b k1 a k , for 0 a k b1 , a k { 0 } + and b + , then

a j = x b j1 b x b j ,

where ≡ the greatest integer function (i.e. floor function) rand j,k + .

Proof. First, evaluate x b j

x= k=1 b k1 a k ( Noperations )

x b j = kj b k1j a k + k>j b k1j a k

Since the floor function is distributive,

x b j = kj b k1j a k + k>j b k1j a k

Because of the condition: 0 a k b1 , only the second term within the first sum survives:

x b j = k>j b k1j

b x b j = k>j b kj a k

x b j1 = kj b kj a k + k>j b kj a k

Only the a j term in the first sum survives {because of the geometric series} while the complete sum becomes:

x b j1 = a j + k>j b kj a k

b x b j = k>j b kj a k

x b j1 b x b j = a j + k>j b kj a k k>j b kj a k

x b j1 b x b j = a j

Corollary:

Observe that this result is easily invertible:

x a j1 a x a j = b j

Example (1): First, convert 407 to base 4 using the standard recursion approach:

407/4 =101remainder=3

101/4 =25remainder=1

25/4 =6remainder=1

6/4 =1remainder=2

1/4 =0remainder=1

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:

407 4 407 4 =3

407 4 4 407 16 =1

407 16 4 407 64 =1

407 64 4 407 256 =2

407 256 4 407 1024 =1

407 1024 4 407 2048 =0

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:

0.390625×2=0.78125remainder0

0.78125×2=1.5625remainder1

0.0.5625×2=1.125remainder1

0.125×2=0.25remainder0

0.25×2=0.5remainder0

0.5×2=1remainder1

Therefore,

0.390625= 0.011001 two

Now, use the non-recursive Markov approach, with x = 0.390625, b = 2 and N = 6.

a 1 = 2 6 ( 0.3900625 ) 2 2 5 ( 0.3900625 ) =1

a 2 = 2 5 ( 0.3900625 ) 2 2 4 ( 0.3900625 ) =0

a 3 = 2 4 ( 0.3900625 ) 2 2 3 ( 0.3900625 ) =0

a 4 = 2 3 ( 0.3900625 ) 2 2 2 ( 0.3900625 ) =1

a 5 = 2 2 ( 0.3900625 ) 2 2 1 ( 0.3900625 ) =1

a 6 = 2 1 ( 0.3900625 ) 2 2 0 ( 0.3900625 ) =0

Thus, we get the same result:

0.390625= 0.011001 two

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.

Conflicts of Interest

The author declares no conflicts of interest regarding the publication of this paper.

References

[1] Matula, D.W. (1968) The Base Conversion Theorem. Proceedings of the American Mathematical Society, 19, 716-723.
[2] Hardy, G.H. and Wright, E.M. (1954) An Introduction to the Theory of Numbers. 3rd Edition, Clarendon Press, Oxford, England.
[3] Robertson, J.E. (1958) A New Class of Digital Division Methods. IRE Transactions on Electronic Computers, EC-7, 218-222.
https://doi.org/10.1109/TEC.1958.5222579
[4] Wilson, J.B. and Ledley, R.S. (1961) An Algorithm for Rapid Binary Division. IRE Transactions on Electronic Computers, 12, 662-670.
[5] Matula, D.W. (1967) Base Conversion Mappings. 1967 Spring Joint Computer Conference, AFIPS Proceedings, 30, 311-318.
https://doi.org/10.1145/1465482.1465532
[6] Matula, D.W. (1967) Base Conversion Mappings. American Federation of Information Processing Societies, 30, 311-318.
[7] Agrawal, D.P. (1975) Arithmetic Algorithms in a Negative Base. IEEE Transactions on Computers, 10, 998-1000.
[8] DeRegt, M.P. (1967) Negative Radix Arithmetic. Computer Design, 6, 52-63.
[9] Abramowitz, M. and Stegun, I.A. (Eds.) (1972) Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. 9th Printing, Dover, New York, p. 10.
[10] Arfken, G. (1985) Mathematical Methods for Physicists. 3rd Edition, Academic Press, Orlando, FL, 278-279.

Copyright © 2025 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.