Balanced ternary

From Wikipedia, the free encyclopedia

Balanced ternary is a ternary numeral system (i.e. base 3 with three digits) that uses a balanced signed-digit representation of the integers in which the digits have the values −1, 0, and 1. This stands in contrast to the standard (unbalanced) ternary system, in which digits have values 0, 1 and 2. The balanced ternary system can represent all integers without using a separate minus sign; the value of the leading non-zero digit of a number has the sign of the number itself. The balanced ternary system is an example of a non-standard positional numeral system. It was used in some early computers[1] and also in some solutions of balance puzzles.[2]

Different sources use different glyphs used to represent the three digits in balanced ternary. In this article, T (which resembles a ligature of the minus sign and 1) represents −1, while 0 and 1 represent themselves. Other conventions include using '−' and '+' to represent −1 and 1 respectively, or using Greek letter theta (Θ), which resembles a minus sign in a circle, to represent −1. In publications about the Setun computer, −1 is represented as overturned 1: "1".[1]

Balanced ternary makes an early appearance in Michael Stifel's book Arithmetica Integra (1544).[3] It also occurs in the works of Johannes Kepler and Léon Lalanne. Related signed-digit schemes in other bases have been discussed by John Colson, John Leslie, Augustin-Louis Cauchy, and possibly even the ancient Indian Vedas.[2]

Definition[]

Let denote the set of symbols (also called glyphs or characters) , where the symbol is sometimes used in place of Define an integer-valued function by

[note 1] and

where the right hand sides are integers with their usual (decimal) values. This function, is what rigorously and formally establishes how integer values are assigned to the symbols/glyphs in One benefit of this formalism is that the definition of "the integers" (however they may be defined) is not conflated with any particular system for writing/representing them; in this way, these two distinct (albeit closely related) concepts are kept separate.

The set together with the function forms a balanced signed-digit representation called the balanced ternary system. It can be used to represent integers and real numbers.

Ternary integer evaluation[]

Let be the Kleene plus of , which is the set of all finite length concatenated strings of one or more symbols (called its digits) where is a non-negative integer and all digits are taken from The start of is the symbol (at the right), its end is (at the left), and its length is . The ternary evaluation is the function defined by assigning to every string the integer

The string represents (with respect to ) the integer The value may alternatively be denoted by The map is surjective but not injective since, for example, However, every integer has exactly one representation under that does not end (on the left) with the symbol i.e.

If and then satisfies:

which shows that satisfies a sort of recurrence relation. This recurrence relation has the initial condition where is the empty string.

This implies that for every string

which in words says that leading symbols (to the left in a string with 2 or more symbols) do not affect the resulting value.

The following examples illustrate how some values of can be computed, where (as before) all integer are written in decimal (base 10) and all elements of are just symbols.

and using the above recurrence relation

Conversion to decimal[]

In the balanced ternary system the value of a digit n places left of the radix point is the product of the digit and 3n. This is useful when converting between decimal and balanced ternary. In the following the strings denoting balanced ternary carry the suffix, bal3. For instance,

10bal3 = 1 × 31 + 0 × 30 = 310
10