HOME

TheInfoList



OR:

In mathematics, a ternary operation is an ''n''- ary
operation Operation or Operations may refer to: Arts, entertainment and media * ''Operation'' (game), a battery-operated board game that challenges dexterity * Operation (music), a term used in musical set theory * ''Operations'' (magazine), Multi-Man ...
with ''n'' = 3. A ternary operation on a set ''A'' takes any given three elements of ''A'' and combines them to form a single element of ''A''. In
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
, a ternary operator is an
operator Operator may refer to: Mathematics * A symbol indicating a mathematical operation * Logical operator or logical connective in mathematical logic * Operator (mathematics), mapping that acts on elements of a space to produce elements of another ...
that takes three
arguments An argument is a statement or group of statements called premises intended to determine the degree of truth or acceptability of another statement called conclusion. Arguments can be studied from three main perspectives: the logical, the dialectic ...
as input and returns one output.


Examples

The function T(a, b, c) = ab + c is an example of a ternary operation on the
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
s (or on any structure where + and \times are both defined). Properties of this ternary operation have been used to define planar ternary rings in the foundations of
projective geometry In mathematics, projective geometry is the study of geometric properties that are invariant with respect to projective transformations. This means that, compared to elementary Euclidean geometry, projective geometry has a different setting, pr ...
. In the
Euclidean plane In mathematics, the Euclidean plane is a Euclidean space of dimension two. That is, a geometric setting in which two real quantities are required to determine the position of each point ( element of the plane), which includes affine notions ...
with points ''a'', ''b'', ''c'' referred to an origin, the ternary operation , b, c= a - b + c has been used to define
free vector In mathematics, physics, and engineering, a Euclidean vector or simply a vector (sometimes called a geometric vector or spatial vector) is a geometric object that has magnitude (or length) and direction. Vectors can be added to other vectors ...
s. Since (''abc'') = ''d'' implies ''a'' – ''b'' = ''c'' – ''d'', these directed segments are equipollent and are associated with the same free vector. Any three points in the plane ''a, b, c'' thus determine a
parallelogram In Euclidean geometry, a parallelogram is a simple (non- self-intersecting) quadrilateral with two pairs of parallel sides. The opposite or facing sides of a parallelogram are of equal length and the opposite angles of a parallelogram are of eq ...
with ''d'' at the fourth vertex. In
projective geometry In mathematics, projective geometry is the study of geometric properties that are invariant with respect to projective transformations. This means that, compared to elementary Euclidean geometry, projective geometry has a different setting, pr ...
, the process of finding a
projective harmonic conjugate In projective geometry, the harmonic conjugate point of an ordered triple of points on the real projective line is defined by the following construction: :Given three collinear points , let be a point not lying on their join and let any line th ...
is a ternary operation on three points. In the diagram, points ''A'', ''B'' and ''P'' determine point ''V'', the harmonic conjugate of ''P'' with respect to ''A'' and ''B''. Point ''R'' and the line through ''P'' can be selected arbitrarily, determining ''C'' and ''D''. Drawing ''AC'' and ''BD'' produces the intersection ''Q'', and ''RQ'' then yields ''V''. Suppose ''A'' and ''B'' are given sets and \mathcal(A, B) is the collection of
binary relation In mathematics, a binary relation associates elements of one set, called the ''domain'', with elements of another set, called the ''codomain''. A binary relation over Set (mathematics), sets and is a new set of ordered pairs consisting of ele ...
s between ''A'' and ''B''. Composition of relations is always defined when ''A'' = ''B'', but otherwise a ternary composition can be defined by , q, r= p q^T r where q^T is the
converse relation In mathematics, the converse relation, or transpose, of a binary relation is the relation that occurs when the order of the elements is switched in the relation. For example, the converse of the relation 'child of' is the relation 'parent&nb ...
of ''q''. Properties of this ternary relation have been used to set the axioms for a
heap Heap or HEAP may refer to: Computing and mathematics * Heap (data structure), a data structure commonly used to implement a priority queue * Heap (mathematics), a generalization of a group * Heap (programming) (or free store), an area of memory f ...
. In
Boolean algebra In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variables are the truth values ''true'' and ''false'', usually denoted 1 and 0, whereas ...
, T(A,B,C) = AC+(1-A)B defines the formula (A \lor B) \land (\lnot A \lor C).


Computer science

In computer science, a ternary operator is an
operator Operator may refer to: Mathematics * A symbol indicating a mathematical operation * Logical operator or logical connective in mathematical logic * Operator (mathematics), mapping that acts on elements of a space to produce elements of another ...
that takes three arguments (or operands). The arguments and result can be of different types. Many
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming l ...
s that use C-like syntax feature a ternary operator, ?:, which defines a conditional expression. In some languages, this operator is referred to as the ''conditional operator''. In Python, the ternary conditional operator reads x if C else y. Python also supports ternary operations called array slicing, e.g. a :c/code> return an array where the first element is a /code> and last element is a -1/code>.
OCaml OCaml ( , formerly Objective Caml) is a general-purpose, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, D ...
expressions provide ternary operations against records, arrays, and strings: a. -c would mean the string a where index b has value c. The
multiply–accumulate operation In computing, especially digital signal processing, the multiply–accumulate (MAC) or multiply-add (MAD) operation is a common step that computes the product of two numbers and adds that product to an accumulator. The hardware unit that performs ...
is another ternary operator. Another example of a ternary operator is ''between'', as used in SQL. The Icon programming language has a "to-by" ternary operator: the expression 1 to 10 by 2 generates the odd integers from 1 through 9. In Excel formulae, the form is =if(C, x, y).


See also

*
Median algebra In mathematics, a median algebra is a set with a ternary operation \langle x,y,z \rangle satisfying a set of axioms which generalise the notions of medians of triples of real numbers and of the Boolean majority function. The axioms are # \lang ...
* ?: for a list of ternary operators in computer programming languages


References


External links

*{{Commons category-inline, Ternary operations