9

Consider the expression

$$|x + 2|x + 3|x + 4|.$$

One way to interpret this is that there are two products being added together:

$$|x+2|x \hspace{1cm} + \hspace{1cm} 3|x+4|$$

But you could also interpret it as the absolute value of an expression that itself contains an absolute value:

$$|x \hspace{1cm} +2|x+3|x \hspace{1cm} +4|$$

These two interpretations are not equivalent. For instance, substituting $x=0{:}$

\begin{align*} |0+2|0 \hspace{1cm} &+ \hspace{1cm} 3|0+4| \hspace{1cm} = 12 \\[7pt] |0 \hspace{1cm} +2|0&+3|0 \hspace{1cm} +4| \hspace{1cm} = 4 \\[7pt] |0 + 2|0 &+ 3|0 + 4| \hspace{2cm} = \,\, ??? \end{align*}

Granted, this is a contrived example and I've never actually seen an ambiguous case come up in real life (or in any math textbook). I only stumbled upon this while developing algorithms to handle edge cases in a free response grader a couple years ago. (And even then, behavior on this edge case doesn't make a difference in practice since none of the correct answers that would be graded against involve ambiguous notation.)

I also realize that the expression could be made un-ambiguous by explicitly writing multiplication symbols, or by tweaking the absolute value notation to distinguish between left bars and right bars (e.g. via sizing/spacing/padding, or by writing $\textrm{abs}(\cdot)$ instead of $|\cdot|$). And I realize that there are obvious ways to solve this issue in the context of software (e.g. designing a user interface that avoids ambiguous notation, or using heuristics like choosing the interpretation with the lowest nesting depth).

But I'm still curious to know: given an ambiguous absolute value expression, is there a standard convention for interpreting it? In other words, loosely speaking, is there a standard "order of operations" for parallel vs nested absolute value expressions, in the absence of clarifying notation?

(The answer may be that there is no agreed-upon rule.)


Update: Dave L Renfro posted a comment "If there is [a standard convention], then it almost certainly would only be applied in a computer coding (or calculator) setting, and it would not generally be known in the mathematical community" which seems convincing enough that there is no agreed-upon rule: mathematicians use symbol sizing (or other notational means) to avoid ambiguity and therefore have no need for a rule to interpret ambiguous cases (since ambiguous cases shouldn't exist in a mathematical text).

I will accept if this comment is posted as an answer or integrated to the parent answer.

Justin Skycak
  • 9,199
  • 4
  • 27
  • 47
  • 20
    I'm praying that people in charge of middle school education don't see this. They love asking students to compute made up stuff like $1-7+3÷4÷1+8\times 3$. Let's not give them any more ideas! – Thierry Nov 10 '23 at 17:29
  • 3
    Is this question really about math education? You might get better answers from StackOverflow or a CS SE site since I think this problem is more likely to come up organically there. Looking at what has been implemented online (WA, etc), they all default to interpretation #1. – Steve Nov 10 '23 at 19:38
  • 2
    I think this is more a math question than a math ed question. – Sue VanHattum Nov 10 '23 at 19:51
  • 2
    Conventions require adoption (usage). From the looks of other comments and light internet "research", the adoption is just not there so by definition there is no such convention. But I cannot prove a negative so leave this as a comment rather than answer. From a pedagogical perspective, clarity of notation should be a priority and questions posed to students should seek to be unambiguous (in notation). – okzoomer Nov 11 '23 at 03:06
  • @SueVanHattum: No. It's obviously a notation question, which is neither. – user21820 Nov 11 '23 at 16:00
  • 1
    This is a bit like a/b/c written with horizontal bars of the same size so you can't tell if it's $ \frac{\frac{a}{b}}{c} = \frac{a}{bc} $ or $ \frac{a}{\frac{b}{c}} = \frac{ac}{b} $ While you can nest parenthesis easily, since the opening and closing ones are distinct, there's no way to tell which fraction bar is the "outer" one, without the visual cue. And similarly there's no way to tell any nesting from the absolute value bars if they're the same size. So, don't do that. (And I'll be happy to give a chewing out to any middle school educator trying that.) – ilkkachu Nov 11 '23 at 18:31
  • 1
    and, well, you did ask "given an ambiguous absolute value expression, is there a standard convention for interpreting it". But that would be impossible, right? If there was a standard convention, then the expression would not be ambiguous, right? And the fact that you have to ask already reveals the answer. :) – ilkkachu Nov 11 '23 at 18:34
  • @ilkkachu a/b/c follows the order of operations for arithmetic. It's not ambiguous strictly speaking. And what I asked does not already reveal the answer because I'm saying an expression looks ambiguous TO ME and asking if is actually not ambiguous according to some standard convention I'm unaware of. – Justin Skycak Nov 11 '23 at 19:41
  • "I also realize that the expression could be made un-ambiguous by explicitly writing multiplication symbols" << The example you gave can indeed be made unambiguous by explicitly writing multiplication symbols, but can it be proven that explicitly writing multiplication symbols always removes the ambiguity? – Stef Nov 13 '23 at 19:01
  • Not an answer, but related https://math.stackexchange.com/q/2642658/27978 – copper.hat Nov 14 '23 at 15:40
  • Wolfram Alpha calculator closes the absolute value as soon as it can reading the expression left to right. Apparently, its creators faced ambiguity in shorthand expressions (when you omit multiplication signs, etc.) too, and it was one of the reasons they decided to display the formula in the standard format that they believe is equivalent to the user input before providing an answer. I think you should either do the same, or to insist on the full syntax including explicit multiplication signs in the user input, which would resolve the ambiguity. – fedja Nov 18 '23 at 05:00

3 Answers3

8

If I want to have nested absolute-value expressions, I would use different sizes $$ \big|x + 2|x + 3|x + 4\big|, $$ with variations possible $$ \bigg|x + 2|x + 3|x + 4\bigg|. $$

Gerald Edgar
  • 7,489
  • 1
  • 21
  • 33
  • 2
    Yes, I'm aware that there are ways to avoid ambiguous cases, but my question is about whether there is a standard convention for interpreting ambiguous cases. – Justin Skycak Nov 10 '23 at 17:30
  • 4
    my question is about whether there is a standard convention for interpreting ambiguous cases --- If there is, then it almost certainly would only be applied in a computer coding (or calculator) setting, and it would not generally be known in the mathematical community, and thus you should instead use appropriate spacing and/or varying absolute value bar sizes. The way I solved this for MS Word MathType (LaTeX might similarly work) in my previous day-job (writing/editing math/quant problems for a well-known international professional school admissions test) was to use (continued) – Dave L Renfro Nov 10 '23 at 21:03
  • 3
    expandable absolute value bars throughout, and for the outer/larger bars, begin and end with a $2 \times 1$ empty column vector (maybe I had to put thin spaces in the entry boxes, I don't remember now). This made the outer absolute bars a bit larger than the inner absolute value bars. However, in your example you can simply put the non-absolute-valued $x$ in front, and maybe also put an extra spaces around the primary plus sign: $x|x + 2| ; + ; 3|x + 4|.$ Thus, rather than look for a standard convention, consider how the expression will actually appear to the reader and adjust accordingly. – Dave L Renfro Nov 10 '23 at 21:03
  • If there is, then it almost certainly would only be applied in a computer coding (or calculator) setting, and it would not generally be known in the mathematical community @DaveLRenfro Thanks, this answers my question: mathematicians use symbol sizing to avoid ambiguity and therefore have no need for a rule to interpret ambiguous cases (as those cases shouldn't exist in a mathematical text). So the standard rule depends on the existence of symbol sizing, so when symbol sizing is not available, there is no standard rule. If you want to turn your comment into an answer, then I'll accept it. – Justin Skycak Nov 10 '23 at 21:42
  • Or, alternatively, if @GeraldEdgar would like to augment his answer to reference what you established in your comment, then I'd be happy to accept that too. – Justin Skycak Nov 10 '23 at 21:44
  • 1
    It's fine with me if Edgar incorporates my comment, although probably only something along the lines of the following is all that's needed: "Rather than trying to maintain some kind of convention, which for this issue almost surely doesn't exist (and if it does exist, then your intended reader will almost surely not know the convention), it would be better to consider how a reader might reasonably interpret the final appearance of the expression and adjust fonts/spacing/symbol-placements accordingly." – Dave L Renfro Nov 11 '23 at 14:53
  • 4
    Even here, the difference in size is slight enough that it's hard for me to tell there is a difference. I would suggest that if anyone ever actually needs that, to consider using a different notation entirely. Just write $ \mathrm{abs}(x) $ or $ [x] $ instead of $ |x| $, and include a note about it in the text. Even if slightly unexpected at first, the result would be clearer in the end. – ilkkachu Nov 11 '23 at 18:40
8

I don't know about standards, but I read these things using a left to right, greedy algorithm. More specifically, the bars are like parentheses but you don't automatically know if they are opening or closing parens. The first one, though, hast to be an opener. The next one going to the right could be an opener or a closer. Try thinking of the expression as if it were a closer first. Does this make sense? Inside your pair of bars and to the right of them? If so, those were a pair. Otherwise, the bar was another opener. Continue this in a recursive fashion.

This procedure would give you the first of the two options and tries to make the nesting depth shallow.

The second of the two options is cursed, blech!

Adam
  • 5,528
  • 18
  • 35
4

As I was looking at your expression, something just seemed typographically off, and then I realized that it was the missing padding around the bars that you see when mathematics is well-typeset. This helps indicate where juxtaposition-as-multiplication is being used. It's subtle, but compare:

$$| x + 2| x + 3| x + 4|$$

$$\left|x + 2\right|x + 3\left|x + 4\right|$$

$$\left|x + 2\left|x + 3\right|x + 4\right|$$

I wouldn't call it any kind of standard, but as a case study I'll mention it. The mathematics library for Lean (mathlib) also noted this parsing ambiguity problem, and the solution they have at the moment is that this notation is parsed outside-in with the longest possible parse, but you must not include any whitespace after the first vertical bar or before the second. This second rule gives you the freedom to control intent. So, to get one interpretation you can write |x + 2| x + 3 |x + 4| and to get the other you can write |x + 2 |x + 3| x + 4|. If you write |x+2|x+3|x+4|, I think it would come out as the second of these, but mathlib does not have juxtaposition for multiplication, so I can't check.

It's worth noting that mathematical notation in general is not really designed to be mechanically interpretable. The conventions we have make it convenient to work with polynomials, rational functions, and expressions to the power of a polynomial. But it's a 2D layout, which is not generally what you'd enter into a computer or calculator, and furthermore it's never in isolation. Notation is a language for communication, and, just like for other human languages, if an author detects what they are saying might be ambiguous given the context, they should disambiguate it in some way.

In an educational setting, I would aim for flagging this ambiguity in student work.

Kyle Miller
  • 181
  • 4