cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Prime Bug - Implicit multiplication

Werner_E
24-Ruby V

Prime Bug - Implicit multiplication

Here is a misbehaviour (already present in real Mathcad, too) that I would classify as a bug, since IMHO an implicit multiplication should be treated exactly the same as an explicitly stated one. An implicit multiplication should be just that and nothing more, not additionally an implicit pair of parenthesis, too.

And, yes, I am aware that some authors use different parsing rules and give priority to implicit multiplications over "normal" multiplications and divisions. But I am not aware of a reliable source that would give implicit multiplication a special place in the order of operators. Although no authoritative literature, Wikipedia also does not grant implicit multiplications a special position. https://en.wikipedia.org/wiki/Order_of_operations

May well lead to endless discussions ... (just search the net for  6:2(1+2)=? ) 🙂

 

Werner_E_0-1655651414751.png

 

8 REPLIES 8
StuartBruff
23-Emerald II
(To:Werner_E)


@Werner_E wrote:

Here is a misbehaviour (already present in real Mathcad, too) that I would classify as a bug, since IMHO an implicit multiplication should be treated exactly the same as an explicitly stated one.

And, yes, I am aware that some authors use different parsing rules and give priority to implicit multiplications over "normal" multiplications and divisions. May well lead to endless discussions ...

 

Werner_E_0-1655651414751.png

 


Your interpretation would seem to be supported by the Prime 8 Help, Werner.

 

You can type expressions such as 5y without inserting the multiplication operator. The scaling operator is automatically inserted between the 5 and the y, and it acts as a multiplication operator.
The scaling operator may not be visible unless you click on the region that contains it. It is recommended that you explicitly use the multiplication operators between expressions that you wish to multiply.
 
This implies that there should be no behavioural difference between implicit and explicit multiplication operations.   OTOH, as you say, there is a case for the alternative interpretation and any bug lying in the documentation, and the "feature" being grandparented in.
 
Is there any difference between the numerical and symbolic engines?
 
Stuart
 


Is there any difference between the numerical and symbolic engines?

No, consistent behaviour

Werner_E_0-1655653424693.png

 

I hardly ever use that inline division operator so its not a big deal - I stumbled over this bug in another forum.

I also am curious if someone can point me to a trustworthy source which defines that different parsing rule where implicit multiplications have precedence over "normal" ones. I have always seen it as a simple abbreviation laid down in a standard.

2h.png

Thats not implicit multiplication but hex postfix.

Ерфтлы, Werner, I know.

Good principle.
Not equal, but similar.

Erftly one more!

We need 20 : 4 = 5 in Russia!

деление.png

LucMeekes
23-Emerald III
(To:Werner_E)

Mathcad 11:

LucMeekes_0-1655721316782.png

Conclusion: the bug is due to the use of the inline division.

To prevent the bug, do not use the inline division operator.

Here's what a standard (ISO 80000-1) says about this topic:

LucMeekes_1-1655721463308.png

LucMeekes_2-1655721810654.png

I guess the 'solidus' is the 'inline division' operator in Mathcad.

If you must use it, follow the standard, that is:"a solidus shall not be followed by a multiplication sign or a division sign..."

Further, ISO 80000-2 has:

LucMeekes_0-1655722917652.png

 

Luc

I can only second the suggestion of the standard  to avoid confusion by adding (mathematically not mandatory) parenthesis for clarity.

But even if you don't do so, the normal rules of math concerning precedence of operators must apply. Division and multiplication are on the same level and so must be applied following the left to right order. Prime and Mathcad do this correctly when you use an explicit multiplication symbol.

So the problem is not any missing pair of parenthesis when using the inline division, but Primes/Mathcads (IMHO inconsistent) handling of the implicit multiplication. So I was looking for some reliable source covering a possible exceptional position of the implicit multiplication to be applied before any other divisions and multiplication - but to no avail. (So I consider the different handling of explicit and implicit multiplication to be a bug.)
The standard is not of much help here as it only succinctly says that you may omit the multiplication symbol "if no misunderstanding is possible". Given that misunderstanding is always possible. this is an unhelpful formulation 😉

Werner_E_0-1655723414806.png

 

Its interesting to see in your screenshot that Maple (symbolic in MC11) correctly deals with the implicit multiplication.

BTW, Wolfram Alpha once again, only adheres to its own rules and yields correctly 4 when you input "4 / 2 * 2", but it gives 1 with "4 : 2 * 2" 🙂

Top Tags