Fact-checked by Grok 2 weeks ago

Unary operation

A unary operation, in , is an operation that takes a single from a set and produces another (possibly the same) within that set, formally defined as a from the set to itself. This contrasts with operations, which require two inputs, and unary operations play a foundational role in by enabling the construction of structures like unary algebras, where all operations are unary. Unary operations are prevalent across mathematical domains, including arithmetic, logic, and set theory. Common examples include the absolute value function on the real numbers, which maps each real number to its non-negative counterpart, ensuring closure within the set. In group theory, the inverse operation—such as additive negation on integers or multiplicative inverse on non-zero rationals—serves as a unary operation that pairs with the group's binary operation to satisfy axioms like associativity and identity. Similarly, the successor function in Peano arithmetic, which increments a natural number by one, exemplifies a unary operation essential for defining the structure of natural numbers. Beyond basic examples, unary operations extend to more specialized contexts, such as the factorial on positive integers, which computes the product of all positive integers up to a given input, or the complex conjugate in complex analysis. Their study emphasizes properties like injectivity, surjectivity, and closure, which determine whether a set remains invariant under the operation, influencing applications in computability, logic, and algebraic modeling.

Fundamentals

Definition

A unary operation, also known as a monadic operation, on a set S is a function \omega: S \to S that maps each element of S to exactly one element in S. This distinguishes it from operations of higher arity, such as binary operations that combine two elements, by requiring precisely one operand as input. The operation acts on a single input, transforming it to produce an output that remains within the same set S, thereby preserving the of the . In , it is typically expressed in the general form \omega(x) where x \in S, emphasizing its role as a from the set to itself. As a fundamental concept in and , unary operations serve as basic building blocks for constructing more complex algebraic structures, enabling the study of transformations on individual elements. The formal study of unary operations emerged within universal algebra, with roots in 19th-century algebraic logic, particularly through George Boole's development of Boolean algebras. The term and its conceptualization were advanced in Alfred North Whitehead's 1898 work A Treatise on Universal Algebra, which laid groundwork for unifying algebraic systems, though the modern definition was solidified by Garrett Birkhoff in 1935 with his paper "On the Structure of Abstract Algebras".

Notation

Unary operations in mathematics are commonly expressed using prefix notation, where the operator precedes the operand, such as −x for the additive inverse or ¬p for logical negation. This convention avoids ambiguity in expression parsing by placing the unary operator directly before its single argument, as seen in the unary minus operator applied to a scalar or the negation symbol in propositional logic. Postfix notation, in contrast, places the operator after the operand and is frequently used for operations like the factorial, denoted as x!, where the exclamation mark follows the input value. This form is prevalent in combinatorial contexts and stack-based evaluation systems, ensuring clear separation from binary operators without requiring parentheses. Infix alternatives for unary operations are rare due to potential ambiguity with binary operators, though the unary minus in expressions like -x is a notable exception, often resolved by operator precedence rules that treat it as prefix despite its positioning. For instance, in -x^2, the unary minus applies only to x, not the entire powered term, highlighting the need for contextual disambiguation. Mathematical typesetting employs various symbols to denote unary operations, including vertical bars for the |x|, which enclose the to indicate its non-negative magnitude. Other conventions include boldface for normalization, hats (e.g., \hat{x} for the unit in the direction of x), and overlines (e.g., \bar{z} for the of z), each visually distinguishing the transformed . These typographic elements enhance readability in printed and digital mathematical texts by clearly signaling the unary transformation. To specify arity and distinguish unary operations from higher-arity functions, notations like those in use terms such as λx. f(), explicitly defining a single-argument through binding. This functional notation underscores the unary nature by limiting the abstraction to one parameter, facilitating composition with other unary operations in higher-order contexts.

Properties

Algebraic structure

In universal algebra, a unary operation is an operation of arity one in the signature of an algebraic structure, interpreted as a function \omega: S \to S on the carrier set S. Endomorphisms of the algebra are unary functions (maps S \to S) that preserve all operations of the structure, forming a monoid under functional composition, while automorphisms are the bijective endomorphisms, forming a group that captures the symmetries of the algebra. The property is inherent to operations in this , as they are defined as functions \omega: S \to S on the carrier set S, ensuring \omega(S) \subseteq S and maintaining the structure's integrity under application. This property underpins the formation of subuniverses, which are subsets closed under all operations, including unary ones. The unary operation, defined by \mathrm{id}(x) = x for all x \in S, acts as the neutral element in the of endomorphisms under composition, preserving every element and serving as a example in various structures like groups. Invertible unary operations are precisely the bijective endomorphisms, whose inverses also preserve the structure, thereby forming the of the . In the specific case of unary algebras (algebras with only unary operations), the consists of bijective endomorphisms that preserve the unary operation(s), with permutations of the carrier set providing basic examples when no further structure is imposed. In structures equipped with an e, such as groups, a unary automorphism \omega satisfies \omega(e) = e, reflecting the preservation of neutral elements under structural mappings. Functional then operates as a on the set of unary operations, enabling the of chaining.

Functional composition

Functional composition allows unary operations to be combined sequentially, enabling the construction of more intricate transformations from simpler ones. For two unary operations \omega and \sigma defined on a set S, the composite operation (\omega \circ \sigma): S \to S is given by (\omega \circ \sigma)(x) = \omega(\sigma(x)) for all x \in S. This process chains the applications, where the output of \sigma serves as the input to \omega, preserving the unary nature since each step operates on a single . A key property of this composition is its associativity, which holds universally for unary operations viewed as functions. Specifically, for unary operations \omega, \sigma, and \tau on S, the equality (\omega \circ (\sigma \circ \tau))(x) = ((\omega \circ \sigma) \circ \tau)(x) is satisfied for all x \in S, allowing parentheses to be omitted without in longer chains. This associativity arises from the underlying structure of and facilitates the analysis of sequences of unary transformations without concern for grouping. Unary operations can also be iterated, meaning applied repeatedly to an element, which is often denoted using exponentiation-like notation to indicate the number of applications. For instance, \omega^2(x) = \omega(\omega(x)), \omega^3(x) = \omega(\omega(\omega(x))), and in general, \omega^n(x) represents the result of applying \omega exactly n times to x, where n is a non-negative and \omega^0(x) = x corresponds to the identity operation. This notation captures the iterative behavior inherent in unary operations, useful in studying such as fixed points or cycles. In category theory, unary operations on a set S are precisely the endomorphisms in the category of sets (\mathbf{Set}), where objects are sets and morphisms are functions; thus, a unary operation \omega: S \to S is a morphism from S to itself. The composition of such endomorphisms forms a monoid structure on the set of all endomorphisms \mathbf{Set}(S, S), with the identity function as the unit, highlighting how unary operations integrate into broader categorical frameworks for algebraic analysis. If a unary operation \omega: S \to S is invertible, possessing an inverse \omega^{-1}: S \to S such that \omega \circ \omega^{-1} = \mathrm{id}_S and \omega^{-1} \circ \omega = \mathrm{id}_S, then the composition yields the identity: (\omega^{-1} \circ \omega)(x) = x for all x \in S. This reversibility underscores the bijective nature of invertible unary operations and their role in preserving structure under composition.

Mathematical examples

Arithmetic and algebraic

In arithmetic and elementary algebra, unary operations are fundamental functions that act on a single operand, typically a real number, to produce another real number within a specified domain. These operations often arise in the context of fields like the real numbers \mathbb{R}, where they preserve algebraic structure while respecting domain restrictions to ensure well-definedness. Common examples include the absolute value, negation, reciprocal, square root, and the successor function, each serving distinct roles in manipulating numerical quantities. The of a x, denoted |x|, is defined as |x| = x if x \geq 0 and |x| = -x if x < 0. This unary operation yields the non-negative magnitude of x, effectively removing its sign while maintaining its distance from zero on the number line. A key property is that |xy| = |x||y| for x and y, which follows from applying the absolute value unary operation to each factor independently. The domain is all \mathbb{R}, with no restrictions, making it universally applicable in arithmetic expressions. Negation, or the additive inverse, maps a real number x to -x, such that x + (-x) = 0. This unary operation reverses the sign of x and is central to the additive group structure of \mathbb{R}. A fundamental identity is the double negation property: -(-x) = x, which underscores its involutory nature—applying it twice returns the original value. The domain encompasses all real numbers \mathbb{R}, as every real has a unique additive inverse. The reciprocal of a nonzero real number x is $1/x, also known as its multiplicative inverse, satisfying x \cdot (1/x) = 1. As a unary operation, it inverts the magnitude while preserving the field's multiplicative structure on \mathbb{R} \setminus \{0\}. This operation is undefined at x = 0, highlighting a critical domain restriction to avoid division by zero, which ensures the result remains in the nonzero reals. The principal square root, denoted \sqrt{x}, extracts the unique nonnegative real number r such that r^2 = x for x \geq 0. This unary operation serves as the inverse of squaring on the nonnegative reals, with the principal branch chosen to guarantee non-negativity. Its domain is restricted to [0, \infty), excluding negative reals where no real solution exists, thereby maintaining closure within the nonnegative reals. The successor function, denoted S(n), maps a natural number n to n + 1, serving as a foundational unary operation in for constructing the natural numbers \mathbb{N} (starting from 0 or 1). It is injective but not surjective on \mathbb{N}, and axioms require that every natural number except 0 has a unique predecessor under the inverse relation. The domain is all natural numbers, ensuring inductive definitions and proofs by induction.

Combinatorial and analytic

In combinatorics, the factorial function serves as a fundamental unary operation that counts the number of permutations of a set of n distinct objects. Defined recursively for non-negative integers n as n! = n \times (n-1)! with the base case $0! = 1, it encapsulates the iterative multiplication process starting from 1 up to n. This recursive structure highlights its unary nature, applying successively to reduce the input by one while accumulating the product. Extending the factorial to the continuum, the \Gamma(z) provides an analytic unary operation on the positive real and complex numbers (excluding non-positive integers), satisfying the functional equation \Gamma(z+1) = z \Gamma(z). For positive integers n, it recovers the factorial via \Gamma(n+1) = n!, thus generalizing combinatorial counts to interpolation over reals and enabling applications in integral calculus and probability distributions. The function is meromorphic, with poles at non-positive integers, and its values grow superexponentially for large positive arguments. Trigonometric functions such as sine and cosine exemplify unary operations in real analysis, mapping real numbers (typically angles in radians) to the interval [-1, 1]. The sine function, \sin(x), is defined as the y-coordinate on the unit circle for angle x, exhibiting periodicity with period $2\pi and odd symmetry. Similarly, \cos(x) is the x-coordinate, even, and also periodic with $2\pi, together forming a basis for and oscillatory phenomena. These properties arise from their differential relations, like \frac{d}{dx} \sin(x) = \cos(x). The exponential function, \exp(x) = e^x where e \approx 2.71828 is the base of the natural logarithm, represents a canonical unary operation with profound analytic growth characteristics. It satisfies \exp(x) > 0 for all real x, is strictly increasing, and its equals itself, \frac{d}{dx} \exp(x) = \exp(x), underscoring its role as the of differentiation. For positive x, it exhibits rapid superexponential growth, dominating polynomials and underpinning models in continuous time. The of a z = a + bi, denoted \overline{z} or z^*, maps it to a - bi, where a and b are real and i is the . This unary operation reverses the imaginary part's sign and is an (\overline{\overline{z}} = z), preserving and real part while enabling operations like computing norms in . The is all complex numbers \mathbb{C}, with applications in roots and inner products. In , differentiation acts as a unary on differentiable , denoted \frac{d}{dx} f(x) or f'(x), which measures the instantaneous rate of change at a point. Formally, f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}, transforming a into its and enabling the study of tangents, optimization, and motion. This is linear over the reals and composable with itself to yield higher-order derivatives, forming the backbone of and physics.

Computing applications

Programming languages

In general-purpose programming languages, unary operations are typically expressed using prefix notation, where the precedes its , mirroring mathematical conventions but adapted to computational semantics. Common unary operators include the logical NOT (!x), which inverts the boolean value of its ; the bitwise NOT (~x), which flips the bits of an integer; the unary minus (-x), which negates a numeric value; and the increment (++x or x++) and decrement (--x or x--) operators, which modify a by adding or subtracting one. These operators apply to modifiable lvalues in languages like , where increment and decrement alter the in place, while in , they coerce non-numeric types to numbers before modification. Type considerations vary by language: in , the logical NOT (!x) treats any scalar type (, floats, pointers) as false if zero and true otherwise, yielding an result of 1 or 0; bitwise NOT (~x) is restricted to types and performs inversion; unary minus (-x) works on arithmetic types, promoting if necessary. In , !x coerces any value to a (falsy values like 0, , or empty strings become true after inversion) and returns the opposite ; ~x coerces to a 32-bit signed before bit inversion, often yielding unexpected results for non- like ~true equaling -2; and -x converts strings or to numbers for negation, such as -"5" resulting in -5. Languages in the C family also feature specialized unary operators like sizeof(x), which returns the byte size of its unevaluated as a size_t, applicable to any type, and the address-of operator (&x), which yields a pointer to the operand's memory location, introducing pointer semantics essential for dynamic . Unary operators generally have high precedence, evaluated before binary operators and from right to left when multiple are chained, ensuring expressions like - -x negate twice to yield x. In , prefix unary operators (including !, ~, -, ++, --) share precedence level 14, while postfix ++ and -- have even higher at level 15, allowing x++ + y to increment x after adding its original value to y. This precedence prevents common errors in mixed expressions, such as treating !true == false correctly without parentheses. For example, in JavaScript, the logical NOT is often used for falsy checks: !0 evaluates to true, confirming zero's falsiness, while double negation !!x coerces any value to its explicit boolean form, useful for type conversion. Pre-increment ++i in a loop updates i before its use, as in for (let i = 0; i < 5; ++i) console.log(i);, printing 0 through 4. In C-family languages like C, !x on an integer x = 5 returns 0 (false), bitwise ~5 inverts to -6 on a typical two's complement system, and &arr[0] obtains the address of the first array element for pointer arithmetic. The sizeof operator aids memory-aware programming, such as sizeof(int*) returning the pointer size (often 8 bytes on 64-bit systems), independent of the pointed-to type's size.

Command-line and scripting

In shell environments, unary commands operate on a single input, such as a or standard input stream. For instance, the cat command concatenates and displays the content of one specified to standard output. Similarly, the wc command performs word, line, , and byte counts on a single provided as input. In , unary operators include tests like -f, which checks if a given argument is a regular that exists. The ! operator serves as a logical NOT in conditional expressions, negating the result of a subsequent test, such as ! -f [file](/page/File) to verify a is not a regular . In arithmetic expansion, ! also acts as logical negation; for example, echo $((!0)) evaluates to 1 since it negates false (0) to true (1). Additionally, ! enables history expansion, where !cmd recalls and executes a previous command matching "cmd" from the session . PowerShell supports unary operations through cmdlets and operators that process single inputs. The Get-Content cmdlet retrieves the content of one specified path, such as a file, returning it as an array of lines. The Test-Path cmdlet acts as a unary test, returning $true if a single path exists and $false otherwise. For numeric negation, the unary minus operator (-) inverts the sign of a value, as in -$a where $a = 5 yields -5. Shell pipelining chains unary operations using the | operator, where the output of one command becomes the single input stream for the next, enabling modular data processing akin to functional composition. For example, [cat](/page/Cat) file | [wc](/page/WC) applies [cat](/page/Cat) to read the file and pipes its output as a unified stream to [wc](/page/WC) for counting.

References

  1. [1]
    [PDF] 8.2 Closure of a Set Under an Operation
    An operation that takes just one element of the set and gives another (possibly the same) element of the set is called a unary operation. An example would be ...Missing: mathematics | Show results with:mathematics
  2. [2]
    Unary Algebras
    Definition. A \emph{unary algebra} is a structure A=⟨A,(fi:∈I)⟩ A = ⟨ A , ( f i :∈ I ) ⟩ of type ⟨1:i∈I⟩ ⟨ 1 : i ∈ I ⟩ such that fi is a unary operation on A ...Missing: mathematics | Show results with:mathematics
  3. [3]
    [PDF] 1 Algebras
    An algebra A is called unary if all of its operations are unary. An ... A group is a monoid along with a unary operation −1 called multiplicative inverse.Missing: abstract | Show results with:abstract
  4. [4]
    [PDF] 5. Peano arithmetic and Gödel's incompleteness theorem
    S, a unary function symbol, taken to be 6. 0, an ... First we have the successor function s, which assigns to each natural number m its successor.
  5. [5]
    [PDF] Algebras - A General Survey
    Groups. A group is a set, S, with a single binary operation, ·, and an inverse (or unary operation), x-1. The operations on a set are often described by some ...
  6. [6]
    [PDF] A Course in Universal Algebra - Department of Mathematics
    Then we add the nullary operations ha, ai for each a ∈ A, a unary operation s defined by s(ha, bi) = hb, ai, and a binary operation t defined by t(ha, bi ...
  7. [7]
    [PDF] COS 360 Programming Languages Prof. Briggs Formal Notations
    For homely examples, the non-numeric symbols in −3, 4 + 5, 6! illustrate a prefix unary operator, an infix binary operator, and a postfix unary operator ...
  8. [8]
    [PDF] Introduction to Mathematical Logic, Handout 1 Propositional Formulas
    ) The symbols. ¬ ∧ ∨ → are called propositional connectives. Among them, ¬ (negation) is a unary connective, and the symbols ∧ (conjunction) ...
  9. [9]
    Absolute Value -- from Wolfram MathWorld
    The absolute value of a real number x is denoted |x| and defined as the "unsigned" portion of x, where sgn(x) is the sign function.
  10. [10]
    Functions: Notation and Terminology - Abstractmath.org
    The symbol "!" denoting the factorial function is normally written in postfix notation. ... In math English, those who use prefix notation (the usual notation) ...<|control11|><|separator|>
  11. [11]
    Infix, Prefix, and Postfix Expressions | Baeldung on Computer Science
    Apr 14, 2023 · Furthermore, the prefix notation can easily handle unary operators, while infix and postfix notations require special handling. The infix ...
  12. [12]
    Transpose -- from Wolfram MathWorld
    For a second-tensor rank tensor a_(ij), the tensor transpose is simply a_(ji). The matrix transpose, most commonly written A^(T), is the matrix obtained by ...
  13. [13]
    The Lambda Calculus - Stanford Encyclopedia of Philosophy
    Dec 12, 2012 · The \(\lambda\)-calculus is, at heart, a simple notation for functions and application. The main ideas are applying a function to an argument and forming ...Brief history of \(\lambda... · \(\lambda\)-theories · Semantics of \(\lambda\)-calculus
  14. [14]
    AUTOMORPHISM GROUPS OF UNARY ALGEBRAS ON GROUPS
    This paper presents a systematic study of the automorphism groups of those unary (universal) algebras 21 = (G; F) whose carrier set G is the carrier.
  15. [15]
    [PDF] Category Theory in Context Emily Riehl
    Mar 1, 2014 · The aim of theory really is, to a great extent, that of systematically organizing past experience in such a way that the next generation, ...
  16. [16]
    [PDF] Algebra in a Category - Daniel Murfet
    Oct 5, 2006 · In the topos Sets we build algebraic structures out of sets and operations (morphisms between sets) where the operations are required to ...
  17. [17]
    Unary Operation -- from Wolfram MathWorld
    More generally, a unary operation is a function with exactly one operand, such as the factorial, square root, or NOT.
  18. [18]
    Additive Inverse -- from Wolfram MathWorld
    ### Summary of Additive Inverse (Wolfram MathWorld)
  19. [19]
    Reciprocal -- from Wolfram MathWorld
    ### Summary of Reciprocal from Wolfram MathWorld
  20. [20]
    Square Root -- from Wolfram MathWorld
    ### Summary of Principal Square Root (Real Numbers)
  21. [21]
    Factorial -- from Wolfram MathWorld
    - **Definition**: The factorial \( n! \) is defined for a positive integer \( n \) as \( n! = n(n-1)\dots2\cdot1 \).
  22. [22]
    Gamma Function -- from Wolfram MathWorld
    The (complete) gamma function Gamma(n) is defined to be an extension of the factorial to complex and real number arguments.Missing: recursive | Show results with:recursive
  23. [23]
    Sine -- from Wolfram MathWorld
    - **Definition**: Sine is a unary function from reals to reals, defined as the vertical coordinate of an arc endpoint on the unit circle for an angle θ measured counterclockwise from the x-axis, or as the ratio of the opposite side to the hypotenuse in a right triangle (sinθ = opposite/hypotenuse).
  24. [24]
    Exponential Function -- from Wolfram MathWorld
    ### Summary of Exponential Function (exp(x) or e^x)
  25. [25]
    Derivative -- from Wolfram MathWorld
    ### Summary of Derivative as a Unary Operator in Calculus
  26. [26]
    Expressions and operators - JavaScript | MDN
    ### Summary of Unary Operators in JavaScript
  27. [27]
    Increment (++) - JavaScript - MDN Web Docs - Mozilla
    Jul 8, 2025 · The increment (++) operator increments (adds one to) its operand and returns the value before or after the increment, depending on where the ...
  28. [28]
  29. [29]
  30. [30]
  31. [31]
  32. [32]
    Operator precedence - JavaScript - MDN Web Docs - Mozilla
    Sep 22, 2025 · For postfix unary operators (namely, ++ and -- ), the same rules apply. Luckily, both operators have higher precedence than any binary operator ...
  33. [33]
    cat Command in Linux / Unix with examples - nixCraft
    Feb 11, 2025 · Unix / Linux cat command examples, basic guide, usage, and syntax for viewing text files on a Linux, macOS, FreeBSD, and Unix-like system.
  34. [34]
    wc Linux Command with Examples | phoenixNAP KB
    Apr 5, 2022 · Use wc to count the number of characters, words, lines, and bytes in a file or standard input. This tutorial will provide details about the wc command and its ...
  35. [35]
    Bash Conditional Expressions (Bash Reference Manual)
    ### Summary of Unary Operators in Bash Conditional Expressions
  36. [36]
  37. [37]
  38. [38]
  39. [39]
  40. [40]
  41. [41]
    The Unix Shell: Pipes and Filters - Software Carpentry Lessons
    Jul 25, 2025 · This idea of linking programs together is why Unix has been so successful. Instead of creating enormous programs that try to do many different ...