Optimal radix choice explained

In mathematics and computer science, optimal radix choice is the problem of choosing the base, or radix, that is best suited for representing numbers. Various proposals have been made to quantify the relative costs of using different radices in representing numbers, especially in computer systems. One formula is the number of digits needed to express it in that base, multiplied by the base (the number of possible values each digit could have). This expression also arises in questions regarding organizational structure, networking, and other fields.

Definition

The cost of representing a number N in a given base b can be defined as

E(b,N)=b\lfloorlogb(N)+1\rfloor

logb

.

If both b and N are positive integers, then the quantity

E(b,N)

is equal to the number of digits needed to express the number N in base b, multiplied by base b.[1] This quantity thus measures the cost of storing or processing the number N in base b if the cost of each "digit" is proportional to b. A base with a lower average

E(b,N)

is therefore, in some senses, more efficient than a base with a higher average value.

For example, 100 in decimal has three digits, so its cost of representation is 10×3 = 30, while its binary representation has seven digits (11001002), so the analogous calculation gives 2×7 = 14. Likewise, in base 3 its representation has five digits (102013), for a value of 3×5 = 15, and in base 36 (2S36) one finds 36×2 = 72.

If the number is imagined to be represented by a combination lock or a tally counter, in which each wheel has b digit faces, from

0,1,...,b-1

and having

\lfloorlogb(N)+1\rfloor

wheels, then

E(b,N)

is the total number of digit faces needed to inclusively represent any integer from 0 to N.

Asymptotic behavior

The quantity

E(b,N)

for large N can be approximated as follows:

E(b,N)=b\lfloorlogb(N)+1\rfloor\simb logb(N)={b\overln(b)}ln(N).

{E(b,N)\overln(N)}\sim{b\overln(b)}.

The asymptotically best value is obtained for base 3, since

b\overln(b)

attains a minimum for

b=3

in the positive integers:

{2\overln(2)}2.88539,

{3\overln(3)}2.73072,

{4\overln(4)}2.88539.

For base 10, we have:

{10\overln(10)}4.34294.

Comparing different bases

The values of

E(b,N)

of bases b1 and b2 may be compared for a large value of N:

{{E(b1,N)}\over{E(b2,N)}}{{b1

{log
b1

(N)}}\over{b2

{log
b2

(N)}}} ={\left(\dfrac{b1ln(N)}{ln(b1)}\right)\over\left(\dfrac{b2ln(N)}{ln(b2)}\right)}={{b1ln(b2)}\over{b2ln(b1)}}.

Choosing e for b2 gives

{{E(b)}\over{E(e)}}{{bln(e)}\over{eln(b)}}={{b}\over{eln(b)}}.

The average

E(b,N)

of various bases up to several arbitrary numbers (avoiding proximity to powers of 2 through 12 and e) are given in the table below. Also shown are the values relative to that of base e.

E(1,N)

of any number

N

is just

N

, making unary the most economical for the first few integers, but this no longer holds as N climbs to infinity.
Base bAvg. E(b,N)N = 1 to 6Avg. E(b,N)N = 1 to 43Avg. E(b,N)N = 1 to 182Avg. E(b,N)N = 1 to 5329

{{E(b)}\over{E(e)}}

Relative size of
E (b )/E (e )
13.522.091.52,665.0

infty

-
24.79.313.322.9
e4.59.012.922.1
35.09.513.122.2
46.010.314.223.9
56.711.715.826.3
67.012.416.728.3
77.013.018.931.3
88.014.720.933.0
99.016.322.634.6
1010.017.924.137.9
1212.020.925.843.8
1515.025.128.849.8
1616.026.430.750.9
2020.031.237.958.4
3030.039.855.284.8
4040.043.771.4107.7
6060.060.0100.5138.8

Ternary tree efficiency

One result of the relative economy of base 3 is that ternary search trees offer an efficient strategy for retrieving elements of a database.[2] A similar analysis suggests that the optimum design of a large telephone menu system to minimise the number of menu choices that the average customer must listen to (i.e. the product of the number of choices per menu and the number of menu levels) is to have three choices per menu.[1]

In a -ary heap, a priority queue data structure based on -ary trees, the worst-case number of comparisons per operation in a heap containing

n

elements is

dlogdn

(up to lower-order terms), the same formula used above. It has been suggested that choosing

d=3

or

d=4

may offer optimal performance in practice.[3]

Brian Hayes suggests that

E(b,N)

may be the appropriate measure for the complexity of an Interactive voice response menu: in a tree-structured phone menu with

n

outcomes and

r

choices per step, the time to traverse the menu is proportional to the product of

r

(the time to present the choices at each step) with

logrn

(the number of choices that need to be made to determine the outcome). From this analysis, the optimal number of choices per step in such a menu is three.[1]

Computer hardware efficiencies

The 1950 reference High-Speed Computing Devices describes a particular situation using contemporary technology. Each digit of a number would be stored as the state of a ring counter composed of several triodes. Whether vacuum tubes or thyratrons, the triodes were the most expensive part of a counter. For small radices r less than about 7, a single digit required r triodes.[4] (Larger radices required 2r triodes arranged as r flip-flops, as in ENIAC's decimal counters.)[5]

So the number of triodes in a numerical register with n digits was rn. In order to represent numbers up to 106, the following numbers of tubes were needed:

Radix rTubes N = rn
239.20
338.24
439.20
542.90
1060.00

The authors conclude,

See also

Further reading

Notes and References

  1. Third Base . Brian Hayes . Brian Hayes (scientist) . . 89 . 6 . 2001 . 490 . 10.1511/2001.40.3268 . 2013-07-28 . https://web.archive.org/web/20140111055213/http://www.americanscientist.org/issues/pub/2001/11/third-base . 2014-01-11 . dead .
  2. Web site: Ternary Search Trees . Bentley . Jon . Sedgewick . Bob . 1998-04-01 . Dr. Dobb's Journal . UBM Tech . 2013-07-28.
  3. Book: Tarjan, R. E. . Robert Tarjan . 3.2. d-heaps . 34–38 . . CBMS-NSF Regional Conference Series in Applied Mathematics . Data Structures and Network Algorithms . 44 . 1983.
  4. Book: Engineering Research Associates Staff . High-Speed Computing Devices . McGraw-Hill . 1950 . 22–23 . 3-6 The r-triode Counter, Modulo r . 2008-08-27.
  5. Book: Engineering Research Associates Staff . High-Speed Computing Devices . McGraw-Hill . 1950 . 23–25 . 3-7 The 2r-triode Counter, Modulo r . 2008-08-27.