Why is the absolute value function or modulus function $|x|$ used ? What are its uses?

For example the square of a modulus number will always be positive, but why is it used when for example the square of any number whether positive or negative is always positive ? For example, $X^2$, will give a positive number whether negative or positive where $X$ is any number positive or negative.

  • 4
    $\begingroup$ $x^2\ne |x|$ so if I want the positive value of $x$ , how would I "just do" $x^2$? $\endgroup$ – John Douma Dec 22 '18 at 19:26
  • $\begingroup$ I’m just giving an example. What is the use of the modulus function ? $\endgroup$ – Dan Dec 22 '18 at 19:27
  • $\begingroup$ Obviously: Getting the absolute value of a number. $\endgroup$ – Henrik Dec 22 '18 at 19:33
  • 4
    $\begingroup$ It has many uses. Have you had Calculus? It is used in definitions where we only care about the distance between two points regardless of which one is greater. e.g. $|x-c|\lt\delta\implies |f(x)-f(c)|\lt\epsilon$. $\endgroup$ – John Douma Dec 22 '18 at 19:33
  • 7
    $\begingroup$ The absolute value has use in absolutely every application of mathematics, pun intended. $\endgroup$ – Matt Samuel Dec 22 '18 at 20:47

In the context of real numbers the absolute value of a number is used in many ways but perhaps very elementarily it is used to write numbers in a canonical form. Every real number $a\ne 0$ is uniquely equal to $\pm \left |a\right|$. So if we define the sign function $s\colon \mathbb R\setminus\{0\}\to \{+,-\}$ given by $s(a)=+$ if $a>0$ and $s(a)=-$ if $a<0$, then: for all $a\ne 0$ in $\mathbb R$ we have $a=sign(a)\cdot \left | a \right |$. In a sense this is a way to build all the reals from the positive ones. This is all just a special case of the polar representation of complex numbers, a representation of utmost importance.


One use of it is to define the distance between numbers. For example, in Calculus, you may want to say "the distance between $x$ and $y$ is less than $1$". The way to write that mathematically is $|x-y|<1$. And you want to write it mathematically so you can work with it mathematically.


The notation $\vert x\vert$ for absolute value of $x$ was introduced by Weierstrass in 1841:

K. Weierstrass, Mathematische Werke, Vol. I (Berlin, 1894), p. 67.

Quoted from [1]

...There has been a real need in analysis for a convenient symbolism for "absolute value" of a given number, or "absolute number," and the two vertical bars introduced in 1841 by Weierstrass, as in $\vert z\vert$, have met with wide adoption;...

Extra information: Absolute is from the Latin absoluere, "to free from"; hence suggesting, to free from its sign.

[1] Florian Cajori, A History of Mathematical Notations (Two volumes bound as one), Dover Publications, 1993.

My take on a usage example of absolute value: $$ min(x,y)=\frac{1}{2}(|x+y|-|x-y|) $$ $$ max(x,y)=\frac{1}{2}(|x+y|+|x-y|) $$

  • $\begingroup$ @HansLundmark me too, that was the reason why I have another reference, let me write it down. Done. $\endgroup$ – Picaud Vincent Dec 22 '18 at 19:50

Because both of them are useful.

You explicitly mentioned the square function. Therefore, I want to give some examples. The main idea is that the non-differentiability of $|\cdot|$ is useful in minimization problem.


We know that the arithmetic mean $\hat{\mu}=\sum_{i=1}^n x_i$ gives

$$\min_{\mu} \,(x_i-\mu)^2$$

but it is less well-known that the median gives

$$\min_{\mu} \, |x_i-\mu|.$$

Signal Processing

Let's use image processing as an example. Suppose $g$ is a given, noisy image. We want to find some smoother image $f$ which looks like $g$.

The Harmonic L$^2$ minimization model solves

$$-\bigtriangleup f + f = g $$

and it turns out to be equivalent to solving a minimization problem:

$$\min_{f} \,(\int_{\Omega} (f(x,y)-g(x,y))^2 dxdy + \int_{\Omega} |\nabla{f(x,y)}|^2 dxdy).$$

An enhanced version is the ROF model. It solves

$$\min_{f} \,(\frac{1}{2} \int_{\Omega} (f(x,y)-g(x,y))^2 dxdy + \lambda \int_{\Omega} |\nabla{f(x,y)}| dxdy).$$

Notice that for appropriate $\lambda$, these two models only differ by a square. Another remark is that $|\cdot|$ gives the Euclidean norm when the argument is a vector. However, the idea still applies since the norm is non-zero

Model Selection

In classical model selection problem, we are given a set of predictors and a response (in vector form). We want to decide which predictors are useful. One way is to choose a "good" subset of predictors. Another way is to shrink the regression coefficients.

The classical regression model solves the following minimization problem:

$$\min_{\beta_0,...,\beta_p} \sum_{i=1}^n (y_i-\beta_0-\sum_{j=1}^p \beta_j x_{ij})^2$$

The Ridge Regression solves the following:

$$\min_{\beta_0,...,\beta_p} \sum_{i=1}^n (y_i-\beta_0-\sum_{j=1}^p \beta_j x_{ij})^2+\lambda \sum_{j=1}^p {\beta_j}^2$$

, so that larger $\beta_j$ gives penalty.

Another version is Lasso, which solves

$$\min_{\beta_0,...,\beta_p} \sum_{i=1}^n (y_i-\beta_0-\sum_{j=1}^p \beta_j x_{ij})^2+\lambda \sum_{j=1}^p |\beta_j|.$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.