5
$\begingroup$

What is the correct definition of the absolute value of $x$, $|x|$?

Option A

$$ |x|= \begin{cases} -x&\text{if } x < 0\\ 0& \text{if } x=0\\ x&\text{if } x>0 \end{cases} $$

Option B

$$ |x|= \begin{cases} -x&\text{if } x \leq 0\\ x&\text{if } x>0 \end{cases} $$

Option C

$$ |x|= \begin{cases} -x&\text{if } x < 0\\ x&\text{if } x\geq 0 \end{cases} $$

  • 21
    They’re all correct: they all define exactly the same function.2012-10-05
  • 2
    ...that is, assuming $x\in\mathbb R$. If $x$ is complex, then the more appropriate definition is $\sqrt{(\Re x)^2+(\Im x)^2}$, where $\Re x$ and $\Im x$ are the real and imaginary parts of $x$.2012-10-05
  • 1
    From a computer science point of view, Option C is better, because it requires one check and one operation for negative values. Option B is a scooch slower if $x=0$2012-10-05
  • 0
    "The" correct definition is the one given previously in that book.2012-10-05
  • 2
    DISTANCE FROM ZERO2012-10-05
  • 0
    From a computer science viewpoint, you'd understand the bitwise representation of numbers and take advantage of that. If a sign-magnitude representation is used, then you would simply produce a copy of the number in which the sign bit has been cleared, and you are done. Sign-magnitude is rare for integers at the machine level, but nearly ubiquitous for floating point, and common in implementations of bignum integers.2012-10-05

4 Answers 4

12

What about Option D? That is:

$$|x|=\begin{cases}-x & x<0\\ x^2 & x=0,x=1\\ x & \text{otherwise}.\end{cases}$$

In all seriousness, there are infinitely-many (seemingly) distinct ways to define $|x|$ piecewise, but in the end, they are precisely the same. All you've got to do is pick one.

  • 0
    So among others, when do you prefer your definition?2012-10-05
  • 5
    @ガベージコレクタ: You don’t even need to define it piecewise: $|x|=\sqrt{x^2}$ also works.2012-10-05
  • 2
    I *don't* prefer my definition. I was simply providing yet another alternative to illustrate the point. Quite frankly, if I had to pick one (though I can't think why I would), I'd probably go with Brian's excellent suggestion, just to avoid dealing with piecewise functions unnecessarily.2012-10-05
  • 0
    Different functions which compute exactly the same thing over the same domains are not precisely the same. They do not *express* the computation in the same way. They are only the same in situations when you don't care what the formula looks like (because, say, you don't intend to manipulate it).2012-10-05
  • 0
    @Kaz: You're talking about computations and formulae, not about functions.2012-10-05
  • 0
    Depends on your definition of function, Kaz. If you mean a set of ordered pairs with each first component corresponding to only one second component, then "functions which compute exactly the same thing over the same domains" **are** precisely the same function, regardless of how they are respectively described--sets are equal if and only if they contain all the same elements, after all. Now, if you mean a rule and a domain, then you're arguably right that different (though equivalent) rules yield different functions.2012-10-05
  • 0
    @BrianM.Scott: why leave out the complex numbers? $|z|=\sqrt{zz^{\bar}}$2012-10-05
  • 0
    @user3490: Because the question is obviously about the absolute value function on $\Bbb R$.2012-10-05
  • 0
    To me, this question looks like it is about about how a function is expressed in formulas, not only about the function as an abstract relation between sets. It is even tagged with the `notation` tag.2012-10-05
11

There are many equivalent ways describing $|x|$ as a function of $x$, what about: $\max\{x,-x\}$?

It is important to remember that the way to describe a set is not important, what important is the set itself.

I can tell you to take three rights; or I could just tell you to take one left. The input is the same and the output is the same, and that is what matters.

In the context of the real numbers there are several ways to describe the absolute value, and they are all the same.

2

A function is both a rule and a domain on which that rule takes place. If, for two functions, the rule and the domain are the same, then the two functions are the same. Just to be clear, you gave several different rules, but they are all equivalent, i.e., they all agree for any $x$ you insert. And all of them have the same domain. So, they are all the same function. Which definition is best only depends on what you are working on.

For example, when you want to find the $\lim\limits_{x \to 0^-} \frac{|x|}{x}$, then any of your definitions will do just fine, and all work better than say $|x| = \max\{x, -x\}$ or $\sqrt{x^2}$.

$$\lim_{x \to 0^-} \frac{|x|}{x} = \lim_{x \to 0^-} \frac{-x}{x} = \lim_{x \to 0^-} -1 = -1$$

But, in other situations, maybe you'd prefer $\sqrt{x^2}$ for some reason.

0

Form C is the most elegant, because it breaks the problem into exactly the right cases: the subdomain of $x$ for which something has to be done to produce the absolute value, and a subdomain which is already identical to its absolute value. Only if $x$ is negative do we have to negate it, otherwise we leave it as is.

Option B is simply silly. Why include 0 in the domain that requires negating?

Option A is verbose, but it has a certain symmetry. In any case, it is better than B because at least it regards 0 as special (which it generally is, even if not specifically in this situation), rather than clumping it with the negatives.