# How to write absolute value as a "true" function

Here's the basic absolute value ... what?

\begin{align*} |x| = \left\{ \begin{array}{r@{\quad \mathrm{if} \quad}l} x & x > 0, \\ 0 & x = 0, \\ \!\! -x & x < 0. \end{array} \right. \end{align*}

Is this a function, an "expression," or just some short-hand statement? How would you categorize this? Could it be a function if I wrote it like this?

\begin{align*} f(x) = \left\{ \begin{array}{r@{\quad \mathrm{if} \quad}l} x & x > 0, \\ 0 & x = 0, \\ \!\! -x & x < 0. \end{array} \right. \end{align*}

or is this not really a proper algebra function format?

• It's a definition by cases, shown using standard notation. The three cases in the rightmost column are mutually exclusive (really only two are needed — $x\ge 0$, and $x<0$). If $x>0$ then $|x| = x$; if $x=0$ then $|0| = 0$; ... Get it? Feb 12, 2016 at 3:00
• That second equation is perfectly fine. Feb 12, 2016 at 3:08
• Note that a "function" is basically any rule for turning numbers into other numbers. It doesn't have to be defined by a simple formula. Feb 12, 2016 at 3:09

That is correct; it is a piecewise function. One comment: you may simply define $f(x) = x$ when $x \geq 0$ and $f(x) = -x$ when $x < 0$. There is no need to break it into three pieces by separating out the $x = 0$ case.

It is a function, defined by cases. Instead of writing $|x|$ using a notation like $abs(x)$ is also perfectly valid. Whether a function has a special notation is just depending on the convention and context.

For example, the determinant of a matrix $\det(A)$ is also written as $|A|$.

A function is simply a way of assigning outputs to inputs. Whether you use $f(x)$ or $|x|$ to denote application of your function to $x$, and whether you define your function by:

\begin{aligned} f(x) &= 2x + 4\\ f(x) &= \text{the number of times 2 appears in the prime factorization of x}\\ f(x) &= \left\{ \begin{array}{r@{\quad \mathrm{if} \quad}l} -17 & |x - 2| < 5 \\ 0 & |x - 2| \ge 5 \end{array} \right. \end{aligned}

it is still a function. One function can be written down in multiple different ways, for example:

$$f(x) = \left\{ \begin{array}{r@{\quad \mathrm{if} \quad}l} x^2 & x > 0 \\ 0 & x = 0 \\ \!\! x^2 & x < 0 \end{array} \right.$$

and

$$f(x) = x^2$$

are the same function.

One alternative to the piecewise definition is, $$|x|=\sqrt{x^2}.$$

The second equation is valid. $f (x)$ is a shorthand notation for some function that takes in some value $x$ on a specified domain and returns some value on a range. So, given the definition of $|x|$ in your question, if you label it as $f (x)$ then you have $f (x)=|x|$ which is essentially what you wrote for your second equation.

• I know that I am five years late to the party but: one of the biggest problems that students seem to have in understanding what functions are and how they work is that they cannot distinguish between a function $f$, and the value $f(x)$ of that function when evaluated at a point in the domain. $f(x)$ is not shorthand notation for a function. It is notation for the value of a function at a point $x$. I have downvoted this answer because I think that it reinforces this common confusion. Dec 4, 2020 at 23:37
• @XanderHenderson I don’t think you read my whole answer here. “f(x) is a shorthand notation that takes in some value x on a specified domain and returns some value on a range. It is then implied that f(x) is a value produced from an input value, x, from the domain. Maybe your issue is with my use of the word “shorthand” in this context. Dec 6, 2020 at 17:06
• I did read your answer. $f(x)$ is not shorthand notation for some function. $f(x)$ is notation for the value of a function $f$, when evaluated at $f$. If you mean to say that "$f(x)$ is a value produced from an input value, $x$, from the domain," then say that. It is not implicit in your answer. This is an extremely common source of confusion for students, and your answer does nothing to alleviate this confusion. Dec 6, 2020 at 19:05

By definition, a function consists of three data: (1) a domain, (2) a codomain, and (3) a way of identifying elements of the domain with elements of the codomain. So, for example, the function $$f: \mathbb{R} \to \mathbb{R} : x \mapsto x^2$$ is the function which takes real numbers to real numbers by squaring them. We often think of a function as being a "machine" or "rule" which takes an input (an element of the domain) and produces an output (an element of the codomain). With this point of view in mind, standard notation is to write $$f(x)$$ to denote the element of the codomain which corresponds to the element $$x$$ in the domain. Thus $$f$$ is a function, while $$f(x)$$ is a value in the codomain of the function. In the case of the function described above, for any $$x$$ in the domain of $$f$$, $$f(x) = x^2$$.

When we write something like $$f(x) = \begin{cases} x & \text{if x \ge 0, and} \\ -x & \text{if x < 0,} \end{cases}$$ we are indicating that $$f$$ is a function which has the property that the value $$f(x)$$ which corresponds to some $$x$$ in its domain is determined by the given piecewise formula. Again, $$f(x)$$ is "just" some element of the codomain (or, really, the range) of the function $$f$$.

However, we often elide the "name" of a function when we define that function in terms of some formula, or introduce some other notation instead of a name. The absolute value function is an example of this. When we write $$|x| = \begin{cases} x & \text{if x \ge 0, and} \\ -x & \text{if x < 0,} \end{cases} \tag{1}$$ we are saying that the value $$|x|$$ (called the absolute value of $$x$$) is defined by the formula on the right. Personally, I would say that the mathematical object at (1) is an "identity"—we are identifying the notation $$|x|$$ (which denotes a number) with the expression on the right.

This identity defines a function, i.e. the absolute value function, but $$|x|$$ is not that function. If you want to refer to the function itself (rather than a value taken by the function), you are going to have to introduce some new notation (or just use a lot of words). For example, if you want to refer to the absolute value function (rather than the absolute value of an input), you could write $$|\cdot|, \qquad \operatorname{abs}, \qquad\text{or}\qquad d(\cdot,0),$$ where the last expression denotes the distance from zero. The variable $$x$$ is absent from all of these notations, as the goal is to refer to the function, and not the values of the function.

There are other times when the standard notation for a function consists of some notation, rather than a letter (or letters) which name that function. For example

• $$\|\cdot\|$$ is used to denote the norm of a vector,
• $$\lfloor \cdot \rfloor$$ and $$\lceil \cdot \rceil$$ are often used to denote the floor and ceiling functions,
• $$(\cdot,\cdot)$$ or $$\langle \cdot, \cdot \rangle$$ are often used to denote an inner product, or (possibly) even
• $$+$$, which is a function on $$\mathbb{R}^2$$ which maps the ordered pair of real numbers $$(a,b)$$ to the real number $$a+b$$.