An operation on a set $S$ is a relationship (rule, correspondence) that assigns to each ordered pair of elements of $S$ a uniquely determined element of $S.$ Thus, an operation is a mapping from the Cartesian product of $S$ with $S,$ denoted by $S\times S = S^2,$ to $S.$ For instance, $+:\Z^2\rightarrow\Z$ defined by $(a,b)\mapsto a+b,$ is the operation of addition on the integers, and $-:\Z^2\rightarrow\Z$ defined by $(a,b)\mapsto a-b$ the operation of subtraction on the integers.

Multiplication is an operation on the set of positive integers, $(m,n)\mapsto mn$ where $mn$ has the usual meaning, $m$ times $n.$ Division is not an operation on the set of positive integers since $m\div n$ is not necessarily a positive integer.

To have an operation $\alpha$ on a set $S,$ it is necessary that if $a,b\in S$ then $\alpha(a,b)\in S.$ This property of an operation is referred to as closure, or we say that $S$ is closed with respect to the operation. Note how the language suggests a mapping may be an operation on one set but not another. If there is an established symbol for an operation, it is used. Otherwise, we may generically use $*$ or juxtaposition as in $(a,b)\mapsto a*b$ or $(a,b)\mapsto ab$ to denote the operation, where it must be specified what $a*b$ or $ab$ mean in each case.

If $*$ be defined by $m*n=m^n$ for all positive integers $m$ and $n,$ then $*$ is an operation on the set of positive integers. Notice that $2*3=2^3=8$ but $3*2=3^2=9$ so that, like subtraction, order matters.

Let $S$ be a nonempty set and $M(S)$ the set of all mappings from $S$ to $S.$ That is, \[ M(S)=\{\alpha\mid \alpha:S\rightarrow S \}. \] If $\alpha,\beta\in M(S)$ then $\beta\circ\alpha\in M(S).$ Therefore, composition $(\circ)$ is an operation on $M(S)$ and $(\beta,\alpha)\mapsto\beta\circ\alpha.$

We may specify an operation by means of a Cayley table, named after British Mathematician Arthur Cayley (1821-1895). The familiar multiplication table is an example. For operation $*,$ we put $a*b$ at the intersection of the horizontal row with $a$ at the left and the vertical column with $b$ at the top. The Cayley table for an operation on a set $S$ has $\abs{S}^2$ entries in it. For instance, if $\abs{S}=3$ then each way of filling 9 entries of the square with elements chosen from $S$ is a distinct operation on $S.$ If the nine entries are left unchanged but $*$ is changed to some other symbol, then the result is not a different operation.

Let $M(2,\R)$ be the set of all $2\times2$ matrices with real numbers as entries. Then matrix addition and matrix multiplication are operations on $M(2,\R)$ as follows: \[ \left[ \begin{matrix} a&b\\ c&d \end{matrix} \right] + \left[ \begin{matrix} w&x\\ y&z \end{matrix} \right] = \left[ \begin{matrix} a+w&b+x\\ c+y&d+z \end{matrix} \right] \] and \[ \left[ \begin{matrix} a&b\\ c&d \end{matrix} \right] \left[ \begin{matrix} w&x\\ y&z \end{matrix} \right] = \left[ \begin{matrix} aw+by&ax+bz\\ cw+dy&cx+dz \end{matrix} \right] \] More generally, for any positive integer $n,$ both matrix multiplication and matrix addition are operations on the set of all $n\times n$ matrices with real numbers as entries, denoted by $M(n,\R).$

A mapping $\alpha:S^2\rightarrow S$ which we refer to as an operation is more precisely called a binary operation on $S.$ A mapping $\alpha:S\rightarrow S$ such as $a\mapsto -a$ is a unary operation on $S.$ A mapping $\alpha:S^3\rightarrow S$ such as $(a,b,c)\mapsto a(b+c)$ is a ternary operation on $S.$ In general, a mapping $\alpha:S^n\rightarrow S$ is an $n$-ary operation on $S.$ The value $n$ is the so-called "arity" of the operation. In this text, the word "operation" refers to binary operation, since other arities are not discussed.

The notion of operation is so fundamental in algebra that algebra could almost be defined as the study of operations, with binary operations being most important. However, such a definition is too general to be of much use. In calculus, for example, it is not all functions $f:\R\rightarrow\R$ that are of interest, but only those having certain properties such as continuity or differentiability. In the same way, the operations of interest in algebra usually possess certain special properties. Some important ones follow.

Associative Law. An operation $*$ on a set $S$ is said to be associative if it satisfies the condition $a*(b*c)=(a*b)*c$ for all $a,b,c\in S.$

Addition and multiplication on $\R$ are associative but subtraction on $\R$ and the operation defined in are not.

If the equation given by the Associative Law fails for even one triple $(a,b,c)$ then the operation is not associative.

An element $e$ in a set $S$ is an identity (or identity element) for an operation $*$ on $S$ if $e*a=a*e=a$ for each $a\in S.$

The identity element is unique if it exists. (Problem 3.23c)

The identity element for addition of integers is $0$ and the identity for multiplication of integers is $1.$ Note, by definition, if, for some $a\in S,$ either $e*a=a$ but $a*e\ne a,$ or $a*e=a$ but $e*a\ne a,$ then $e$ is not an identity element for operation $*$ on $S.$

Assume that $*$ is an operation on $S,$ with identity $e,$ and that $a\in S.$ An element $b$ in $S$ is an inverse of $a$ relative to $*$ if $a*b=b*a=e.$

Contrast the language. A mapping is not required to have an identity element to be an operation, but to be an identity element $e,$ the equation given in the definition of identity must hold for every $a\in S.$ Similarly, elements of $S$ need not have inverses for a mapping to be an operation on $S.$ However, unlike the identity element, an inverse may exist for some elements and not others. Also, when it exists, there is only one identity for all elements of $S,$ whereas each element of $S$ may have its own distinct inverse.

Relative to addition on the set of integers, each integer has an inverse, its negative: $a+(-a)=(-a)+a=0$ for each integer $a.$ Note that the inverse must be in the operation's set. For instance, relative to addition on the set of nonnegative integers, no element has an inverse but $0:$ The inverse of a positive integer is negative.

Relative to multiplication on the set of real numbers, each non-zero real number has an inverse, its reciprocal: $a\cdot(1/a)=(1/a)\cdot a = 1.$ Multiplication on the set of integers is also an operation, but only $1$ and $-1$ have inverses.

Commutative Law. An operation $*$ on a set $S$ is said to be commutative if $a*b=b*a$ for all $a,b\in S.$

Addition and multiplication of integers are commutative.