Precisely stated, a function
is binary if there exists sets
Set-theoretically, a binary function can be represented as a subset of the Cartesian product
defines a binary function if and only if for any
Even when thought of this way, however, one generally writes
(That is, the same pair of parentheses is used to indicate both function application and the formation of an ordered pair.)
Division of whole numbers can be thought of as a function.
is the set of natural numbers (except for zero), and
is the set of rational numbers, then division is a binary function
In a vector space V over a field F, scalar multiplication is a binary function.
A scalar a ∈ F is combined with a vector v ∈ V to produce a new vector av ∈ V. Another example is that of inner products, or more generally functions of the form
, where x, y are real-valued vectors of appropriate size and M is a matrix.
If M is a positive definite matrix, this yields an inner product.
[1] Functions whose domain is a subset of
are often also called functions of two variables even if their domain does not form a rectangle and thus the cartesian product of two sets.
[2] In turn, one can also derive ordinary functions of one variable from a binary function.
In computer science, this identification between a function from
For example, the division example above is surjective (or onto) because every rational number may be expressed as a quotient of an integer and a natural number.
However, it's not injective in both variables simultaneously, because (for example) f (2,4) = f (1,2).
One can also consider partial binary functions, which may be defined only for certain values of the inputs.
For example, the division example above may also be interpreted as a partial binary function from Z and N to Q, where N is the set of all natural numbers, including zero.
But this function is undefined when the second input is zero.
A binary operation is a binary function where the sets X, Y, and Z are all equal; binary operations are often used to define algebraic structures.
In linear algebra, a bilinear transformation is a binary function where the sets X, Y, and Z are all vector spaces and the derived functions f x and fy are all linear transformations.
However, the bilinear transformation can also be interpreted as a single linear transformation from the tensor product
One can also define an A-ary function where A is any set; there is one input for each element of A.
In category theory, n-ary functions generalise to n-ary morphisms in a multicategory.
The interpretation of an n-ary morphism as an ordinary morphisms whose domain is some sort of product of the domains of the original n-ary morphism will work in a monoidal category.
The construction of the derived morphisms of one variable will work in a closed monoidal category.
The category of sets is closed monoidal, but so is the category of vector spaces, giving the notion of bilinear transformation above.