HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, a ternary operation is an ''n''-
ary ARY may stand for: * Abdul Razzak Yaqoob, a Pakistani expatriate businessman * Andre Romelle Young, real name of Dr. Dre * Ary and the Secret of Seasons, an action adventure video game * ARY Digital, a Pakistani television network * ARY Digital Net ...
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 Set, The Set, SET or SETS may refer to: Science, technology, and mathematics Mathematics *Set (mathematics), a collection of elements *Category of sets, the category whose objects and morphisms are sets and total functions, respectively Electro ...
''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 Applied science, practical discipli ...
, a ternary operator is an operator 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 languag ...
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, ...
. 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 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
= a - b + c has been used to define free vectors. 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, ...
, 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 ...
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 sets and is a new set of ordered pairs consisting of elements in and in ...
s between ''A'' and ''B''.
Composition of relations In the mathematics of binary relations, the composition of relations is the forming of a new binary relation from two given binary relations ''R'' and ''S''. In the calculus of relations, the composition of relations is called relative multiplica ...
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&n ...
of ''q''. Properties of this ternary relation have been used to set the axioms for a heap. 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 i ...
, 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 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 ...
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 Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. ...
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 perfor ...
is another ternary operator. Another example of a ternary operator is ''between'', as used in SQL. The
Icon programming language : Icon is a very high-level programming language based on the concept of "goal-directed execution" in which code returns a "success" along with valid values, or a "failure", indicating that there is no valid data to return. The success and failure ...
has a "to-by" ternary operator: the expression 1 to 10 by 2 generates the
odd Odd means unpaired, occasional, strange or unusual, or a person who is viewed as eccentric. Odd may also refer to: Acronym * ODD (Text Encoding Initiative) ("One Document Does it all"), an abstracted literate-programming format for describing X ...
integers from 1 through 9. In Excel formulae, the form is =if(C, x, y).


See also

* Median algebra * ?: for a list of ternary operators in computer programming languages


References


External links

*{{Commons category-inline, Ternary operations