Lably
Skip to content

Balanced ternary

Numeral system using the values -1, 0 and 1

  • 13 min read
  • 6 chapters

Related on Lably

Through Numerical digit, Integer and 0

Different sources use different glyphs 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".

Balanced ternary makes an early appearance in Michael Stifel's book Arithmetica Integra (1544). 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.

Definition

Let D3:={T,0,1} denote the set of symbols (also called glyphs or characters), where the symbol 1¯ is sometimes used in place of T. Define an integer-valued function f=fD3:D3→Z by

f(T)=−1,f(0)=0,f(1)=1,

where the right hand sides are integers with their usual values. This function, f, is what rigorously and formally establishes how integer values are assigned to the symbols/glyphs in D3. 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 D3 together with the function f 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 D3+ be the Kleene plus of D3, which is the set of all finite length concatenated strings dn…d0 of one or more symbols (called its digits) where n is a non-negative integer and all n+1 digits dn,…,d0 are taken from D3={T,0,1}. The start of dn…d0 is the symbol d0 (at the right), its end is dn (at the left), and its length is n+1. The ternary evaluation is the function v=v3:D3+→Z defined by assigning to every string dn…d0∈D3+ the integer

v(dn…d0)=∑i=0nf(di)3i.

The string dn…d0 represents (with respect to v) the integer v(dn…d0). The value v(dn…d0) may alternatively be denoted by dn…d0bal⁡3. The map v:D3+→Z is surjective but not injective since, for example, 0=v(0)=v(00)=v(000)=⋯. However, every nonzero integer has exactly one representation under v that does not end (on the left) with the symbol 0, i.e. dn=0.

If dn…d0∈D3+ and n>0 then v satisfies:

v(dndn−1…d0)=f(dn)3n+v(dn−1…d0)

which shows that v satisfies a sort of recurrence relation. This recurrence relation has the initial condition v(ε)=0 where ε is the empty string.

This implies that for every string dn…d0∈D3+,

v(0dn…d0)=v(dn…d0)

which in words says that leading 0 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 v can be computed, where (as before) all integer are written in decimal (base 10) and all elements of D3+ are just symbols.

v(T⁡T)=f(T)31+f(T)30=(−1)3+(−1)1=−4v(T⁡1)=f(T)31+f(1)30=(−1)3+(1)1=−2v(1T)=f(1)31+f(T)30=(1)3+(−1)1=2v(11)=f(1)31+f(1)30=(1)3+(1)1=4v(1T⁡0)=f(1)32+f(T)31+f(0)30=(1)9+(−1)3+(0)1=6v(10T)=f(1)32+f(0)31+f(T)30=(1)9+(0)3+(−1)1=8

and using the above recurrence relation

v(101T)=f(1)33+v(01T)=(1)27+v(1T)=27+2=29.

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Basics