"Four times a certain number decreased by one", 4(x-1) or 4x-1?

How does the English grammar precedence work if this is the case? Are both variation equally valid?

My initial assumption is that the right answer should be "4(x-1)", and if the sentence had a comma like this "Four times a certain number, decreased by one", then it would be "4x - 1"

If context is needed, I'm making a small web app project that converts such sentences to a math expression.

• You have to distort the use of decreased to make the math ambiguous. Math problems are not written as word problems with the word decreased substituting for minus. 4x minus 1 is represented by 4x-1. And 4 (the value of x decreased by 1) is 4(x-1). Jan 16, 2023 at 5:29

English is not as precise as mathematics. This sentence is simply ambiguous and could equally be interpreted in either of the two possible you mention.

A comma might help:

four times a certain number, decreased by one

Would, I think be unambiguously "4x-1". Or a bit of reworking might help:

a certain number decreased by one then multiplied by four

Would be unambiguously 4(x-1).

However, I think your project may be rather more challenging than you anticipate for this very reason: some English sentences do not map unambiguously to math.

It would be cool if your program could determine all the possibilities and ask the user what they meant. But that is no mean feat.

Such decisions may feel like untangling Gordian knots.

Merriam Webster
Gordian Knot
a problem insoluble in its own terms

Therefore, Occam's Razor is relevant: the simplest interpretation is the one to adopt.

Merriam Webster
Occam's Razor
is interpreted as requiring that the simplest of competing theories be preferred to the more complex

The simplest interpretation is that comprehension should progress in a linear manner unless directed otherwise by convention and punctuation.

Let us call the defined (certain) number Q {it makes a change from x}

Hence "Four times a certain number" is 4Q
then we encounter "decreased by one", making 4Q -1

From the computational perspective, this approach has the advantage that the algorithm may assimilate items sequentially, creating no hanging arithmetic dependencies to be resolved by later punctuation such as commas, parentheses or other parenthetic devices.

{
Unless we proceed in this simplest linear way, we make things even more difficult in cases such as, for example "four times a number decreased by one added to seven times three ...", which is unambiguously interpreted as:
4Q
4Q-1
4Q-1+7
(4Q-1+7)*3
}

• I would have interpreted "four times a number decreased by one added to seven times three" as (4Q-1)+7*3
– Jim
Jan 15, 2023 at 5:22
• @Jim that is just the sort of ambiguity the questioner reasonably points to. However, they also seem happy to accept an answer that does not really resolve the issue, so we need spend no further time on it. Jan 15, 2023 at 7:59