Jump to content

Optimal radix choice: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
as far as I can tell, the term "radix economy" is original research that propagated by citogenesis
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{short description|Number of digits needed to express a number in a particular base}}
{{short description|Number of digits needed to express a number in a particular base}}
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 [[digit (math)|digit]]s 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.
{{Multiple issues|
{{Misleading|talk=Binary has the lowest radix economy for humans|date=May 2024}}
{{One source|date=May 2024}}
}}
The '''radix economy''' of a number in a particular base (or [[radix]]) is the number of [[digit (math)|digit]]s needed to express it in that base, multiplied by the base (the number of possible values each digit could have). This is one of various proposals that have been made to quantify the relative costs of using different radices in representing numbers, especially in computer systems.

Radix economy also has implications for organizational structure, networking, and other fields.


==Definition==
==Definition==
The '''radix economy''' ''E''(''b'',''N'') for any particular number ''N'' in a given base ''b'' is defined as
The cost of representing a number ''N'' in a given base ''b'' can be defined as


: <math>E(b,N) = b \lfloor \log_b (N) +1 \rfloor \, </math>
: <math>E(b,N) = b \lfloor \log_b (N) +1 \rfloor \, </math>
Line 15: Line 9:
where we use the [[Floor and ceiling functions|floor function <math>\lfloor \rfloor</math>]] and the base-b [[logarithm]] <math>\log_{b}</math>.
where we use the [[Floor and ceiling functions|floor function <math>\lfloor \rfloor</math>]] and the base-b [[logarithm]] <math>\log_{b}</math>.


If both ''b'' and ''N'' are positive integers, then the radix economy <math>E(b,N)</math> is equal to the number of [[digit (math)|digit]]s needed to express the number ''N'' in base ''b'', multiplied by base ''b''.<ref name="Hayes">{{cite journal | title = Third Base | author = Brian Hayes | author-link = Brian Hayes (scientist) | journal = [[American Scientist]] | volume = 89 | issue = 6 | year = 2001 | pages = 490 | doi = 10.1511/2001.40.3268 | url=http://www.americanscientist.org/issues/pub/2001/11/third-base | accessdate=2013-07-28 | archive-url = https://web.archive.org/web/20140111055213/http://www.americanscientist.org/issues/pub/2001/11/third-base | archive-date = 2014-01-11 | url-status = dead }}</ref> The radix economy 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 radix economy is therefore, in some senses, more efficient than a base with a higher average radix economy.
If both ''b'' and ''N'' are positive integers, then the quantity <math>E(b,N)</math> is equal to the number of [[digit (math)|digit]]s needed to express the number ''N'' in base ''b'', multiplied by base ''b''.<ref name="Hayes">{{cite journal | title = Third Base | author = Brian Hayes | author-link = Brian Hayes (scientist) | journal = [[American Scientist]] | volume = 89 | issue = 6 | year = 2001 | pages = 490 | doi = 10.1511/2001.40.3268 | url=http://www.americanscientist.org/issues/pub/2001/11/third-base | accessdate=2013-07-28 | archive-url = https://web.archive.org/web/20140111055213/http://www.americanscientist.org/issues/pub/2001/11/third-base | archive-date = 2014-01-11 | url-status = dead }}</ref> 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 <math>E(b,N)</math> is therefore, in some senses, more efficient than a base with a higher average value.


For example, [[100 (number)|100]] in [[decimal]] has three digits, so its radix economy is 10×3&nbsp;=&nbsp;30; its binary representation has seven digits (1100100<sub>2</sub>) so it has radix economy 2×7&nbsp;=&nbsp;14 in base 2; in [[base 3]] its representation has five digits (10201<sub>3</sub>) with a radix economy of 3×5&nbsp;=&nbsp;15; in base 36 (2S<sub>36</sub>) its radix economy is 36×2&nbsp;=&nbsp;72.
For example, [[100 (number)|100]] in [[decimal]] has three digits, so its cost of representation is 10×3&nbsp;=&nbsp;30, while its binary representation has seven digits (1100100<sub>2</sub>), so the analogous calculation gives 2×7&nbsp;=&nbsp;14. Likewise, in [[base 3]] its representation has five digits (10201<sub>3</sub>), for a value of 3×5&nbsp;=&nbsp;15, and in base 36 (2S<sub>36</sub>) one finds 36×2&nbsp;=&nbsp;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 <math>0, 1, ..., b-1</math> and having <math>\lfloor \log_b (N) +1 \rfloor</math> wheels, then the radix economy <math>b \lfloor \log_b (N) +1 \rfloor</math> is the total number of digit faces needed to inclusively represent any integer from 0 to ''N''.
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 <math>0, 1, ..., b-1</math> and having <math>\lfloor \log_b (N) +1 \rfloor</math> wheels, then <math>E(b,N)</math> is the total number of digit faces needed to inclusively represent any integer from 0 to ''N''.


==Asymptotic behavior==
==Asymptotic behavior==
The radix economy for large ''N'' can be approximated as follows:
The quantity <math>E(b,N)</math> for large ''N'' can be approximated as follows:


: <math> E(b,N) = b \lfloor \log_b (N) +1 \rfloor \sim b\ \log_b (N) = {b \over \ln(b)} \ln(N) .</math>
: <math> E(b,N) = b \lfloor \log_b (N) +1 \rfloor \sim b\ \log_b (N) = {b \over \ln(b)} \ln(N) .</math>
: <math> {E(b,N) \over \ln(N)} \sim {b \over \ln(b)} .</math>
: <math> {E(b,N) \over \ln(N)} \sim {b \over \ln(b)} .</math>


The asymptotically best radix economy is obtained for base 3, since <math>b \over \ln(b)</math> attains a minimum for <math>b = 3</math> in the positive integers:
The asymptotically best value is obtained for base 3, since <math>b \over \ln(b)</math> attains a minimum for <math>b = 3</math> in the positive integers:
:<math>{2 \over \ln(2)} \approx 2.88539\,,</math>
:<math>{2 \over \ln(2)} \approx 2.88539\,,</math>
:<math>{3 \over \ln(3)} \approx 2.73072\,,</math>
:<math>{3 \over \ln(3)} \approx 2.73072\,,</math>
Line 35: Line 29:


==Comparing different bases==
==Comparing different bases==
The radix economy of bases ''b''<sub>1</sub> and ''b''<sub>2</sub> may be compared for a large value of ''N'':
The values of <math>E(b,N)</math> of bases ''b''<sub>1</sub> and ''b''<sub>2</sub> may be compared for a large value of ''N'':


: <math> {{E(b_1,N)} \over {E(b_2,N)}} \approx {{b_1 {\log_{b_1} (N)}} \over {b_2 {\log_{b_2} (N)}}}
: <math> {{E(b_1,N)} \over {E(b_2,N)}} \approx {{b_1 {\log_{b_1} (N)}} \over {b_2 {\log_{b_2} (N)}}}
= {\left( \dfrac{b_1 \ln (N)} {\ln (b_1)} \right) \over \left( \dfrac{b_2 \ln (N)} {\ln (b_2)} \right)} = {{b_1 \ln (b_2)} \over {b_2 \ln (b_1)}} \, . </math>
= {\left( \dfrac{b_1 \ln (N)} {\ln (b_1)} \right) \over \left( \dfrac{b_2 \ln (N)} {\ln (b_2)} \right)} = {{b_1 \ln (b_2)} \over {b_2 \ln (b_1)}} \, . </math>


Choosing ''e'' for ''b''<sub>2</sub> gives the economy relative to that of ''e'' by the function:
Choosing ''e'' for ''b''<sub>2</sub> gives


: <math> {{E(b)} \over {E(e)}} \approx {{b \ln (e)} \over {e \ln (b)}} = {{b} \over {e \ln(b)}} \, </math>
: <math> {{E(b)} \over {E(e)}} \approx {{b \ln (e)} \over {e \ln (b)}} = {{b} \over {e \ln(b)}} \, . </math>


The average radix economies 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 radix economies relative to that of ''e''. Note that the radix economy of any number in base 1 is that number, making it the most economical for the first few integers, but as ''N'' climbs to infinity so does its relative economy.
The average <math>E(b,N)</math> 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''. <math>E(1,N)</math> of any number <math>N</math> is just <math>N</math>, making [[Unary numeral system|unary]] the most economical for the first few integers, but this no longer holds as ''N'' climbs to infinity.


:{| class="wikitable sortable"
:{| class="wikitable sortable"
Line 189: Line 183:
==Ternary tree efficiency==
==Ternary tree efficiency==
One result of the relative economy of base 3 is that [[ternary search tree]]s offer an efficient strategy for retrieving elements of a database.<ref>{{cite web |url=http://www.drdobbs.com/database/ternary-search-trees/184410528 |title=Ternary Search Trees |last1=Bentley |first1=Jon |last2=Sedgewick |first2=Bob |date=1998-04-01 |website=Dr. Dobb's Journal |publisher=UBM Tech |accessdate=2013-07-28}}</ref> A similar analysis suggests that the optimum design of a large [[Interactive voice response|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.<ref name="Hayes"/>
One result of the relative economy of base 3 is that [[ternary search tree]]s offer an efficient strategy for retrieving elements of a database.<ref>{{cite web |url=http://www.drdobbs.com/database/ternary-search-trees/184410528 |title=Ternary Search Trees |last1=Bentley |first1=Jon |last2=Sedgewick |first2=Bob |date=1998-04-01 |website=Dr. Dobb's Journal |publisher=UBM Tech |accessdate=2013-07-28}}</ref> A similar analysis suggests that the optimum design of a large [[Interactive voice response|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.<ref name="Hayes"/>

In a [[d-ary heap|{{mvar|d}}-ary heap]], a [[priority queue]] data structure based on {{mvar|d}}-ary trees, the worst-case number of comparisons per operation in a heap containing <math>n</math> elements is <math>d\log_d n</math> (up to lower-order terms), the same formula used above. It has been suggested that choosing <math>d=3</math> or <math>d=4</math> may offer optimal performance in practice.<ref>{{cite book
| last = Tarjan | first = R. E. | author-link = Robert Tarjan
| contribution = 3.2. ''d''-heaps
| pages = 34–38
| publisher = [[Society for Industrial and Applied Mathematics]]
| series = CBMS-NSF Regional Conference Series in Applied Mathematics
| title = Data Structures and Network Algorithms
| volume = 44
| year = 1983}}</ref>

[[Brian Hayes (scientist)|Brian Hayes]] suggests that <math>E(b,N)</math> may be the appropriate measure for the complexity of an [[Interactive voice response]] menu: in a tree-structured phone menu with <math>n</math> outcomes and <math>r</math> choices per step, the time to traverse the menu is proportional to the product of <math>r</math> (the time to present the choices at each step) with <math>\log_r n</math> (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.<ref name="Hayes"/>


==Computer hardware efficiencies==
==Computer hardware efficiencies==
Line 218: Line 224:
The authors conclude,
The authors conclude,
{{quote|Under these assumptions, the radix 3, on the average, is the most economical choice, closely followed by radices 2 and 4. These assumptions are, of course, only approximately valid, and the choice of 2 as a radix is frequently justified on more complete analysis. Even with the optimistic assumption that 10 triodes will yield a decimal ring, radix 10 leads to about one and one-half times the complexity of radix 2, 3, or 4. This is probably significant despite the shallow nature of the argument used here.<ref>{{cite book |author=Engineering Research Associates Staff |title=High-Speed Computing Devices |publisher=McGraw-Hill |year=1950 |pages=84–87 |chapter=6-7 Economy Attained by Radix Choice |url=https://archive.org/details/HighSpeedComputingDevices |accessdate=2008-08-27}}</ref>}}
{{quote|Under these assumptions, the radix 3, on the average, is the most economical choice, closely followed by radices 2 and 4. These assumptions are, of course, only approximately valid, and the choice of 2 as a radix is frequently justified on more complete analysis. Even with the optimistic assumption that 10 triodes will yield a decimal ring, radix 10 leads to about one and one-half times the complexity of radix 2, 3, or 4. This is probably significant despite the shallow nature of the argument used here.<ref>{{cite book |author=Engineering Research Associates Staff |title=High-Speed Computing Devices |publisher=McGraw-Hill |year=1950 |pages=84–87 |chapter=6-7 Economy Attained by Radix Choice |url=https://archive.org/details/HighSpeedComputingDevices |accessdate=2008-08-27}}</ref>}}

==Other criteria==
In another application, the authors of ''High-Speed Computing Devices'' consider the speed with which an encoded number may be sent as a series of high-frequency voltage pulses. For this application the compactness of the representation is more important than in the above storage example. They conclude, "A saving of 58 per cent can be gained in going from a binary to a ternary system. A smaller percentage gain is realized in going from a radix 3 to a radix 4 system."<ref>{{cite book |author=Engineering Research Associates Staff |title=High-Speed Computing Devices |publisher=McGraw-Hill |year=1950 |pages=419–421 |chapter=16-2 New Techniques |url=https://archive.org/details/HighSpeedComputingDevices |accessdate=2008-08-27}}</ref>

Binary encoding has a notable advantage over all other systems: greater noise immunity. Random voltage fluctuations are less likely to generate an erroneous signal, and circuits may be built with wider voltage tolerances and still represent unambiguous values accurately.


==See also==
==See also==

Latest revision as of 19:34, 23 June 2024

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

[edit]

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

where we use the floor function and the base-b logarithm .

If both b and N are positive integers, then the quantity 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 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 and having wheels, then is the total number of digit faces needed to inclusively represent any integer from 0 to N.

Asymptotic behavior

[edit]

The quantity for large N can be approximated as follows:

The asymptotically best value is obtained for base 3, since attains a minimum for in the positive integers:

For base 10, we have:

Comparing different bases

[edit]

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

Choosing e for b2 gives

The average 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. of any number is just , making unary the most economical for the first few integers, but this no longer holds as N climbs to infinity.

Base b Avg. E(b,N)

N = 1 to 6

Avg. E(b,N)

N = 1 to 43

Avg. E(b,N)

N = 1 to 182

Avg. E(b,N)

N = 1 to 5329

Relative size of
E (b )/E (e )
1 3.5 22.0 91.5 2,665.0
2 4.7 9.3 13.3 22.9 1.0615 1.0615
 
e 4.5 9.0 12.9 22.1 1.0000 1
 
3 5.0 9.5 13.1 22.2 1.0046 1.0046
 
4 6.0 10.3 14.2 23.9 1.0615 1.0615
 
5 6.7 11.7 15.8 26.3 1.1429 1.1429
 
6 7.0 12.4 16.7 28.3 1.2319 1.2319
 
7 7.0 13.0 18.9 31.3 1.3234 1.3234
 
8 8.0 14.7 20.9 33.0 1.4153 1.4153
 
9 9.0 16.3 22.6 34.6 1.5069 1.5069
 
10 10.0 17.9 24.1 37.9 1.5977 1.5977
 
12 12.0 20.9 25.8 43.8 1.7765 1.7765
 
15 15.0 25.1 28.8 49.8 2.0377 2.0377
 
16 16.0 26.4 30.7 50.9 2.1230 2.123
 
20 20.0 31.2 37.9 58.4 2.4560 2.456
 
30 30.0 39.8 55.2 84.8 3.2449 3.2449
 
40 40.0 43.7 71.4 107.7 3.9891 3.9891
 
60 60.0 60.0 100.5 138.8 5.3910 5.391
 

Ternary tree efficiency

[edit]

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 d-ary heap, a priority queue data structure based on d-ary trees, the worst-case number of comparisons per operation in a heap containing elements is (up to lower-order terms), the same formula used above. It has been suggested that choosing or may offer optimal performance in practice.[3]

Brian Hayes suggests that may be the appropriate measure for the complexity of an Interactive voice response menu: in a tree-structured phone menu with outcomes and choices per step, the time to traverse the menu is proportional to the product of (the time to present the choices at each step) with (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

[edit]

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 r Tubes N = rn
2 39.20
3 38.24
4 39.20
5 42.90
10 60.00

The authors conclude,

Under these assumptions, the radix 3, on the average, is the most economical choice, closely followed by radices 2 and 4. These assumptions are, of course, only approximately valid, and the choice of 2 as a radix is frequently justified on more complete analysis. Even with the optimistic assumption that 10 triodes will yield a decimal ring, radix 10 leads to about one and one-half times the complexity of radix 2, 3, or 4. This is probably significant despite the shallow nature of the argument used here.[6]

See also

[edit]

References

[edit]
  1. ^ a b c Brian Hayes (2001). "Third Base". American Scientist. 89 (6): 490. doi:10.1511/2001.40.3268. Archived from the original on 2014-01-11. Retrieved 2013-07-28.
  2. ^ Bentley, Jon; Sedgewick, Bob (1998-04-01). "Ternary Search Trees". Dr. Dobb's Journal. UBM Tech. Retrieved 2013-07-28.
  3. ^ Tarjan, R. E. (1983). "3.2. d-heaps". Data Structures and Network Algorithms. CBMS-NSF Regional Conference Series in Applied Mathematics. Vol. 44. Society for Industrial and Applied Mathematics. pp. 34–38.
  4. ^ Engineering Research Associates Staff (1950). "3-6 The r-triode Counter, Modulo r". High-Speed Computing Devices. McGraw-Hill. pp. 22–23. Retrieved 2008-08-27.
  5. ^ Engineering Research Associates Staff (1950). "3-7 The 2r-triode Counter, Modulo r". High-Speed Computing Devices. McGraw-Hill. pp. 23–25. Retrieved 2008-08-27.
  6. ^ Engineering Research Associates Staff (1950). "6-7 Economy Attained by Radix Choice". High-Speed Computing Devices. McGraw-Hill. pp. 84–87. Retrieved 2008-08-27.

Further reading

[edit]
  • S.L. Hurst, "Multiple-Valued Logic-Its Status and its Future", IEEE trans. computers, Vol. C-33, No 12, pp. 1160–1179, DEC 1984.
  • J. T. Butler, "Multiple-Valued Logic in VLSI Design, ” IEEE Computer Society Press Technology Series, 1991.
  • C.M. Allen, D.D. Givone “The Allen-Givone Implementation Oriented Algebra", in Computer Science and Multiple-Valued Logic: Theory and Applications, D.C. Rine, second edition, D.C. Rine, ed., The Elsevier North-Holland, New York, N.Y., 1984. pp. 268–288.
  • G. Abraham, "Multiple-Valued Negative Resistance Integrated Circuits", in Computer Science and Multiple-Valued Logic: Theory and Applications, D.C. Rine, second edition, D.C. Rine, ed., The Elsevier North-Holland, New York, N.Y., 1984. pp. 394–446.