Unary operation (source code)

= Unary operation
{title2=$f:S\to S$}

A unary operation on a <set> $S$ is a <function> $f:S\to S$ taking one input and returning an element of the same <set>. Examples include the <additive inverse> $n\mapsto-n$ on the <integers> and inversion $g\mapsto g^{-1}$ in a <group>.

Unary operations can be composed and iterated. The identity <function> and all maps $S\to S$ form a <monoid> under <function composition>. For negation, $f\circ f=\operatorname{id}$; for a successor map on the nonnegative <integers>, iteration instead produces an unbounded sequence.

An operation's identities are extra data. Being unary alone says nothing about injectivity, surjectivity or whether repeated application returns to the starting element.