Unary Functional Symbol
   HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, an unary operation is an operation with only one operand, i.e. a single input. This is in contrast to
binary operation In mathematics, a binary operation or dyadic operation is a rule for combining two elements (called operands) to produce another element. More formally, a binary operation is an operation of arity two. More specifically, an internal binary op ...
s, which use two operands. An example is any function , where is a set. The function is a unary operation on . Common notations are prefix notation (e.g. Β¬,
βˆ’ The plus and minus signs, and , are mathematical symbols used to represent the notions of positive and negative, respectively. In addition, represents the operation of addition, which results in a sum, while represents subtraction, result ...
),
postfix notation Reverse Polish notation (RPN), also known as reverse Łukasiewicz notation, Polish postfix notation or simply postfix notation, is a mathematical notation in which operators ''follow'' their operands, in contrast to Polish notation (PN), in whi ...
(e.g.
factorial In mathematics, the factorial of a non-negative denoted is the product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial: \begin n! &= n \times (n-1) \times (n-2) \t ...
), functional notation (e.g. or ), and
superscript A subscript or superscript is a character (such as a number or letter) that is set slightly below or above the normal line of type, respectively. It is usually smaller than the rest of the text. Subscripts appear at or below the baseline, whil ...
s (e.g. transpose ). Other notations exist as well, for example, in the case of the square root, a horizontal bar extending the square root sign over the argument can indicate the extent of the argument.


Examples


Unary negative and positive

As unary operations have only one operand they are evaluated before other operations containing them. Here is an example using
negation In logic, negation, also called the logical complement, is an operation that takes a proposition P to another proposition "not P", written \neg P, \mathord P or \overline. It is interpreted intuitively as being true when P is false, and false ...
: :3 βˆ’ βˆ’2 Here, the first 'βˆ’' represents the binary
subtraction Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peachesβ€”meaning 5 peaches with 2 taken ...
operation, while the second 'βˆ’' represents the unary negation of the 2 (or 'βˆ’2' could be taken to mean the integer βˆ’2). Therefore, the expression is equal to: :3 βˆ’ (βˆ’2) = 5 Technically, there is also a unary + operation but it is not needed since we assume an unsigned value to be positive: :+2 = 2 The unary + operation does not change the sign of a negative operation: :+(βˆ’2) = βˆ’2 In this case, a unary negation is needed to change the sign: :βˆ’(βˆ’2) = +2


Trigonometry

In trigonometry, the trigonometric functions, such as \sin, \cos, and \tan, can be seen as unary operations. This is because it is possible to provide only one term as input for these functions and retrieve a result. By contrast, binary operations, such as
addition Addition (usually signified by the Plus and minus signs#Plus sign, plus symbol ) is one of the four basic Operation (mathematics), operations of arithmetic, the other three being subtraction, multiplication and Division (mathematics), division. ...
, require two different terms to compute a result.


Examples from programming languages


JavaScript

In JavaScript, these operators are unary: * Increment: ++x, x++ * Decrement: βˆ’βˆ’x, xβˆ’βˆ’ *Positive: +x *Negative: βˆ’x * Ones' complement: ~x *
Logical negation In logic, negation, also called the logical complement, is an operation that takes a proposition P to another proposition "not P", written \neg P, \mathord P or \overline. It is interpreted intuitively as being true when P is false, and false ...
: !x


C family of languages

In the C family of languages, the following operators are unary: * Increment: ++x, x++ * Decrement: βˆ’βˆ’x, xβˆ’βˆ’ * Address: &x * Indirection: *x *Positive: +x *Negative: βˆ’x * Ones' complement: ~x *
Logical negation In logic, negation, also called the logical complement, is an operation that takes a proposition P to another proposition "not P", written \neg P, \mathord P or \overline. It is interpreted intuitively as being true when P is false, and false ...
: !x * Sizeof: sizeof x, sizeof(type-name) * Cast: (''type-name'') ''cast-expression''


Unix Shell (Bash)

In the Unix/Linux shell (bash/sh), '$' is a unary operator when used for parameter expansion, replacing the name of a variable by its (sometimes modified) value. For example: * Simple expansion: $x * Complex expansion: $


Windows PowerShell

*Increment: ++$x, $x++ *Decrement: βˆ’βˆ’$x, $xβˆ’βˆ’ *Positive: +$x *Negative: βˆ’$x *Logical negation: !$x *
Invoke Invoke may refer to: * Invocation, a form of supplication or prayer * Invoke Solutions, a market research company founded in 1999 and based in the United States * Invoke (smart speaker), developed by Harman Kardon and powered by Microsoft's inte ...
in current
scope Scope or scopes may refer to: People with the surname * Jamie Scope (born 1986), English footballer * John T. Scopes (1900–1970), central figure in the Scopes Trial regarding the teaching of evolution Arts, media, and entertainment * CinemaS ...
: .$x *Invoke in new scope: &$x *Cast: 'type-name''''cast-expression'' *Cast: +$x *Array: ,$array


See also

*
Binary operation In mathematics, a binary operation or dyadic operation is a rule for combining two elements (called operands) to produce another element. More formally, a binary operation is an operation of arity two. More specifically, an internal binary op ...
* Iterated binary operation * Ternary operation *
Arity Arity () is the number of arguments or operands taken by a function, operation or relation in logic, mathematics, and computer science. In mathematics, arity may also be named ''rank'', but this word can have many other meanings in mathematics. In ...
* Operation (mathematics) * Operator (programming)


References

*


External links

* {{DEFAULTSORT:Unary Operation Elementary algebra Operators (programming)