User:Paul August/Altar of the Twelve Gods

In mathematics, the absolute value (or modulus) of a real number is its numerical value without regard to its sign. So, for example, 3 is the absolute value of both 3 and −3.
Generalizations of the absolute value for real numbers are also defined for complex numbers, quaternions, and for elements of ordered rings.
Definition for real numbers
For any real number a, the absolute value of a, is denoted , and is defined as
As can be seen from the above definition, the absolute value of a, is always either positive or zero, never negative. Also notice that
The absolute value can be regarded as the distance along the real number line of a number from zero; indeed the notion of distance in mathematics is a generalisation of the properties of the absolute value. When real numbers are considered as one-dimensional vector space R1, the absolute value is the norm, and the p-norm for any p. Up to a constant factor, every norm in R1 is equal to the absolute value: ||x||=||1||.|x|
Properties
The absolute value has the following properties:
- (the triangle inequality)
The last two properties are often used in solving inequalities; for example:
For real arguments, the absolute value function f(x) = |x| is continuous everywhere and differentiable everywhere except for x = 0. For complex arguments, the function is continuous everywhere but differentiable nowhere (One way to see this is to show that it does not obey the Cauchy-Riemann equations).
For a complex number z = a + ib, one defines the absolute value or modulus to be |z| = √(a2 + b2) = √ (z z*) (see square root and complex conjugate). This notion of absolute value shares the properties 1-6 from above. If one interprets z as a point in the plane, then |z| is the distance of z to the origin.
It is useful to think of the expression |x − y| as the distance between the two numbers x and y (on the real number line if x and y are real, and in the complex plane if x and y are complex). By using this notion of distance, both the set of real numbers and the set of complex numbers become metric spaces.
The function is not invertible, because a negative and a positive number have the same absolute value.
Absolute value and complex numbers
(the modulus)
Algorithm
In the C programming language, the abs()
, labs()
, llabs()
(in C99), fabs()
, fabsf()
, and fabsl()
functions compute the absolute value of an operand. Coding the integer version of the function is trivial, ignoring the boundary case where the largest negative integer is input:
int abs(int i) { if (i < 0) return -i; else return i; }
The floating-point versions are trickier, as they have to contend with special codes for infinity and not-a-numbers.