why balanced ternary exists, what is the problem with ternary

$\begingroup$

Recently, I countered a problem of representing data in ternary. I came to know there exists ternary and balanced ternary representation.

It is my best understanding that balanced ternary helps in computation in some way, exactly how, I do not know.

Why exactly does "balanced" ternary exist? What is the characteristic of standard ternary that makes it "unbalanced"?

$\endgroup$ 5

4 Answers

$\begingroup$

I don't see it mentioned on the Wikipedia page, but my very first thought on learning of balanced ternary was its obvious application to a weighing scale riddle I encountered once:

Given a balance scale and a set of exactly four weights (with whole number weights when measured in ounces), you would like to be able to measure 1 ounce, 2 ounces, 3 ounces, and so on. What should the measures of the four weights be to allow you to measure a maximum of sequential whole number weights?

The answer is that you can measure all exact weights from $1$ to $40$ if the four weights have measures $1, 3, 9, 27$.

Balanced ternary makes this very obvious and also represents, for each number, the placement of weights so as to measure an object with any specified measurement.


As a commentary, reasonably bright students who've never encountered balanced ternary sometimes think of binary as a first approach when asked this riddle, in which case they come up with the incorrect solution $15$ using the four weights $1, 2, 4, 8$.

Ternary does not have obvious application to this riddle. Balanced ternary applies easily: You can either put a weight on one side of the balance scale, or on the other side, or leave it off of the scale. (But you can't put two of a single weight on one side, as would be denoted by regular ternary.)

$\endgroup$ $\begingroup$

Some early computers used balanced ternary at a very base level, so that instead of using bits with a value of 1 or 0 (charge or no charge), they used 'trits' with values of -1, 0, or 1 (negative charge, no charge, or positive charge). This has some advantages, but it did not catch on.

$\endgroup$ $\begingroup$

Volume 2 of Donald Ervin Knuth‘s 3 block series ‘The Art_of_Computer_Programming’, Section 4.1 Seminumerical Algorithms has a brilliant discussion of bases and their advantages & disadvantages... including ternary (0,1,2) and balanced ternary (-1,0,1). He starts this section off with a discussion of how to determine the most efficient base, which turns out to be base ’e’ (e being Euler’s number 2.71828... which is the the base of the natural logarithms).

The most important advantages of using a balanced ternary number system are:

  • Ternary is the closest whole number base to base e and thus the most efficient for implementing non-quantum hardware and software computing systems.

  • Balanced ternary yields significantly lower numerical errors (round-off, overflow, underflow,...) from performing mathematical operations (multiply, divide, Log/Ln...) in hardware or software, compared with non-balanced bases. Note that only odd bases can be balanced (symmetric) about 0 - even bases like binary (base 2) can not be ’balanced.

  • Less hardware is required to implement ternary memory, data buses, compute circuitry... because each wire, memory cell, or logic element transfers, stores, or computes in three states as opposed to two in binary hardware.

  • There have not been any natural 3-state ‘transistor’ Silicon wafer fabrication technologies that can approach the circuit speed and manufacturing cost of the CMOS semiconductor fabrication of our binary computers.

  • Knuth did not address another benefit here in software and algorithms (compilers, OS’s & applications). The ‘what is important & why’ in that regard is left as an exercise for the student.

Be Excellent - Michael

$\endgroup$ $\begingroup$

To answer this question, I will first address the issue of representing negative numbers under binary.

The naive way to do this would be to have a single bit to designate a number to be negative. This has a couple of major disadvantages though, the two biggest being (1) You have two values for zero, a "positive" zero, and a "negative" zero, and (2) there is no easy way to add a negative number to a positive one.

Modern computers overcome this issue by converting negative numbers to "2's compliment". The most intuitive way to understand this is to imagine a byte consisting of all 1 bits; adding 1 to this would set all these values to 0 with an overflow bit of 1. In 2's compliment, we use this as "-1", and count down from there to get our negative numbers.

The nice thing about this approach is that we can use the same logical mechanisms to add two numbers, regardless of whether they are positive or negative.

Theoretically, you can represent negative numbers in ternary by using a "3's compliment", or even in decimal using "10's compliment" (I had done so, just for fun, a couple of weeks ago, which helped me get a better feel for 2's compliment), but balanced ternary is another way we could do it as well, with the added bonus that it's easy to convert a number from positive to negative. (Just change the 1's to -1's and vice versa.)

I would add that balanced ternary is a surprisingly beautiful answer to this problem. There's something pretty amazing about a number system that can represent both positive and negative numbers in such a symmetrical way!

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like