# Is there a standard convention for interpreting ambiguous absolute value expressions?

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.

• 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! Commented Nov 10, 2023 at 17:29
• 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. Commented Nov 10, 2023 at 19:38
• I think this is more a math question than a math ed question. Commented Nov 10, 2023 at 19:51
• 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). Commented Nov 11, 2023 at 3:06
• 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.) Commented Nov 11, 2023 at 18:31

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!

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|.$$

• 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. Commented Nov 10, 2023 at 17:30
• 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) Commented Nov 10, 2023 at 21:03
• 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. Commented Nov 10, 2023 at 21:03
• 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." Commented Nov 11, 2023 at 14:53
• 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. Commented Nov 11, 2023 at 18:40

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.

• Yes. Bingo. Absolutely. :) Commented Nov 14, 2023 at 23:34