Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Balanced ternary
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Definition == {{See also|Signed-digit representation}} Let <math>\mathcal{D}_{3} := \lbrace \operatorname{T}, 0, 1 \rbrace</math> denote the set of [[Symbol (mathematics)|symbols]] (also called ''glyphs'' or ''characters''), where the symbol <math>\bar{1}</math> is sometimes used in place of <math>\operatorname{T}.</math> Define an [[integer]]-valued function <math>f = f_{\mathcal{D}_{3}} : \mathcal{D}_{3} \to \mathbb{Z}</math> by :<math>\begin{align} f_{}(\operatorname{T}) &= -1, \\ f_{}(0) &= 0, \\ f_{}(1) &= 1, \end{align}</math><ref>The symbols <math>0</math> and <math>1</math> appear twice in the equalities <math>f_{}(0) = 0</math> and <math>f_{}(1) = 1,</math> but these instances do not represent the same thing. The right hand side <math>0</math> and <math>1</math> mean the integers <math>\in\Z,</math> but the instances inside <math>f</math>'s parentheses (which belong to <math>\mathcal{D}_{3}</math>) should be thought of as being nothing more than symbols.</ref> where the right hand sides are integers with their usual values. This function, <math>f_{},</math> is what rigorously and formally establishes how integer values are assigned to the symbols/glyphs in <math>\mathcal{D}_{3}.</math> 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 <math>\mathcal{D}_{3}</math> together with the function <math>f_{}</math> 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 <math>\mathcal{D}_{3}^{+}</math> be the [[Kleene plus]] of <math>\mathcal{D}_{3}</math>, which is the set of all finite length [[concatenation|concatenated]] [[String (computer science)|strings]] <math>d_n \ldots d_0</math> of one or more symbols (called its ''digits'') where <math>n</math> is a non-negative integer and all <math>n + 1</math> digits <math>d_n, \ldots, d_0</math> are taken from <math>\mathcal{D}_{3} = \lbrace \operatorname{T}, 0, 1 \rbrace.</math> The ''start'' of <math>d_n \ldots d_0</math> is the symbol <math>d_0</math> (at the right), its ''end'' is <math>d_n</math> (at the left), and its ''length'' is <math>n + 1</math>. The ''ternary evaluation'' is the function <math>v = v_{3} ~:~ \mathcal{D}_{3}^{+} \to \mathbb{Z}</math> defined by assigning to every string <math>d_n \ldots d_0 \in \mathcal{D}_{3}^{+}</math> the integer :<math>v\left( d_n \ldots d_0 \right) ~=~ \sum_{i=0}^{n} f_{} \left( d_{i} \right) 3^{i}.</math> The string <math>d_n \ldots d_0</math> ''represents'' (with respect to <math>v</math>) the integer <math>v\left( d_n \ldots d_0 \right).</math> The value <math>v\left( d_n \ldots d_0 \right)</math> may alternatively be denoted by <math>{d_n \ldots d_0}_{\operatorname{bal}3}.</math> The map <math>v : \mathcal{D}_{3}^{+} \to \mathbb{Z}</math> is [[Surjective map|surjective]] but not injective since, for example, <math>0 = v(0) = v(00) = v(0 0 0) = \cdots.</math> However, every nonzero integer has exactly one representation under <math>v</math> that does not ''end'' (on the left) with the symbol <math>0,</math> i.e. <math>d_n = 0 .</math> If <math>d_n \ldots d_0 \in \mathcal{D}_{3}^{+}</math> and <math>n > 0</math> then <math>v</math> satisfies: :<math>v\left( d_n d_{n-1} \ldots d_0 \right) ~=~ f_{} \left( d_{n} \right) 3^{n} + v\left( d_{n-1} \ldots d_0 \right)</math> which shows that <math>v</math> satisfies a sort of [[recurrence relation]]. This recurrence relation has the initial condition <math>v\left( \varepsilon \right) = 0</math> where <math>\varepsilon</math> is the empty string. This implies that for every string <math>d_n \ldots d_0 \in \mathcal{D}_{3}^{+},</math> :<math>v\left( 0 d_n \ldots d_0 \right) = v\left( d_n \ldots d_0 \right)</math> which in words says that ''leading'' <math>0</math> 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 <math>v</math> can be computed, where (as before) all integer are written in decimal (base 10) and all elements of <math>\mathcal{D}_{3}^{+}</math> are just symbols. :<math>\begin{alignat}{10} v\left( \operatorname{T} \operatorname{T} \right) &= && f_{}\left( \operatorname{T} \right) 3^{1} + && f_{}\left( \operatorname{T} \right) 3^{0} &&= &&(-1) &&3 &&\,+\, &&(-1) &&1 &&= -4 \\ v\left( \operatorname{T} 1 \right) &= && f_{}\left( \operatorname{T} \right) 3^{1} + && f_{}\left( 1 \right) 3^{0} &&= &&(-1) &&3 &&\,+\, &&(1) &&1 &&= -2 \\ v\left( 1 \operatorname{T} \right) &= && f_{}\left( 1 \right) 3^{1} + && f_{}\left( \operatorname{T} \right) 3^{0} &&= &&(1) &&3 &&\,+\, &&(-1) &&1 &&= 2 \\ v\left( 1 1 \right) &= && f_{}\left( 1 \right) 3^{1} + && f_{}\left( 1 \right) 3^{0} &&= &&(1) &&3 &&\,+\, &&(1) &&1 &&= 4 \\ v\left( 1 \operatorname{T} 0 \right) &= f_{}\left( 1 \right) 3^{2} + && f_{}\left( \operatorname{T} \right) 3^{1} + && f_{}\left( 0 \right) 3^{0} &&= (1) 9 \,+\, &&(-1) &&3 &&\,+\, &&(0) &&1 &&= 6 \\ v\left( 1 0 \operatorname{T} \right) &= f_{}\left( 1 \right) 3^{2} + && f_{}\left( 0 \right) 3^{1} + && f_{}\left( \operatorname{T} \right) 3^{0} &&= (1) 9 \,+\, &&(0) &&3 &&\,+\, &&(-1) &&1 &&= 8 \\ \end{alignat} </math> and using the above recurrence relation :<math>v\left( 1 0 1 \operatorname{T} \right) = f_{}\left( 1 \right) 3^{3} + v\left( 0 1 \operatorname{T} \right) = (1) 27 + v\left( 1 \operatorname{T} \right) = 27 + 2 = 29.</math>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)