Commutativity
Commutativity
- A binary operator is commutative if changing the order of the inputs doesn’t change the output.
- For example, addition (
+ ) is commutative becausea + b = b + a for any numbersa andb . - multiplication (
* ) is also commutative:a * b = b * a . - However, subtraction (
- ) and division (/ ) are not commutative:a - b is generally not equal tob - a .a / b is generally not equal tob / a .- Exponentiation (
^) - powers - are also not commutative:a^b is generally not equal tob^a .
Associativity
- A binary operator is associative if the way in which inputs are grouped does not affect the output.
- For example, addition is associative because
(a + b) + c = a + (b + c) for any numbersa ,b , andc . - multiplication is also associative:
(a * b) * c = a * (b * c) . - However, subtraction and division are not associative:
(a - b) - c is generally not equal toa - (b - c) .(a / b) / c is generally not equal toa / (b / c) .- Exponentiation is also not associative:
(a^b)^c is generally not equal toa^(b^c) .
Identity elements
- If
e*a=a*e for ALL values in the set,e is the identity. - For addition, for example, the identity is
0 , because0 + a = a + 0 = a for any numbera . - For multiplication, the identity is
1 , because1 * a = a * 1 = a for any numbera .
The inverse of the identity element is the identity element itself.
Inverse elements
- The inverse element is the
- If
a*b=b*a=e ,a andb are inverse of each other. - For addition, the inverse of a number
a is-a , becausea + (-a) = (-a) + a = 0 . - For multiplication, the inverse of a number
a (assuminga \neq 0 ) is\frac{1}{a} , becausea * \frac{1}{a} = \frac{1}{a} * a = 1 .
Not all binary operators have an inverse.