In mathematics, a binary function (also called bivariate function, or function of two variables) is a function that takes two inputs.
Precisely stated, a function
f
X,Y,Z
f\colonX x Y → Z
X x Y
X
Y.
X x Y x Z
(x,y,z)
f(x,y)=z
R
x\inX
y\inY
z\inZ
(x,y,z)
R
f(x,y)
z
Alternatively, a binary function may be interpreted as simply a function from
X x Y
Z
f(x,y)
f((x,y))
Division of whole numbers can be thought of as a function. If
\Z
\N+
\Q
f:\Z x \N+\to\Q
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
(x,y)\mapstoxTMy
Functions whose domain is a subset of
R2
In turn, one can also derive ordinary functions of one variable from a binary function.Given any element
x\inX
fx
f(x, ⋅ )
Y
Z
fx(y)=f(x,y)
y\inY
fy
f( ⋅ ,y)
X
Z
fy(x)=f(x,y)
X x Y
Z
X
ZY
ZY
Y
Z
The various concepts relating to functions can also be generalised to binary functions.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.This example is injective in each input separately, because the functions f x and f y are always injective.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.
X ⊗ Y
The concept of binary function generalises to ternary (or 3-ary) function, quaternary (or 4-ary) function, or more generally to n-ary function for any natural number n.A 0-ary function to Z is simply given by an element of Z.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.