A **binary operation** on a set *S* is a function of the form
*f* : *S* × *S* `->` *S*.

Binary operations are often written using infix notation such as *a* * *b*, *a* + *b* or *a*.*b* rather than by functional notation of the form *f*(*a*,*b*).
Many binary operations of interest are commutative or associative.

Typical examples of binary operations are the addition and multiplication of numbers as well as *composition of functions*: start with a set *M* and consider two functions *r* : *M* `->` *M* and *s* : *M* `->` *M*. Then *r*o*s* : *M* `->` *M* is the function defined by (*r*o*s*)(*x*) = *r*(*s*(*x*)) for all *x* in *M*. This defines a binary operation o on the set *S* containing all functions from *M* to *M*.

See also binary function.