rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

extra parenthesis added when simp:false #82

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-01 18:05:09 Created by grmaximus on 2017-04-05 12:37:51 Original: https://sourceforge.net/p/maxima/bugs/3299


I'm not sure if this is a bug or intentional, but in older versions of maxima (5.37.3), the following block(simp:false,-2*x) would be -2*x

but in the latest 5.39.0 it gives me extra parenthesis: (-2)*x

should those parenthesis be there?

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-01 18:05:10 Created by robert_dodier on 2017-06-28 22:23:17 Original: https://sourceforge.net/p/maxima/bugs/3299/#eff1


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-01 18:05:12 Created by robert_dodier on 2017-06-28 22:23:17 Original: https://sourceforge.net/p/maxima/bugs/3299/#135a


I think the output with parentheses is correct. The input -2*x is parsed to ((MTIMES) ((MMINUS) 2) $X), that is, (minus 2) times x. MTIMES has a higher precedence than MMINUS, so the parentheses are necessary to disambiguate the display.

A decision was made some time ago (a year or two) to display parentheses which are needed to disambiguate expressions; sometimes this policy leads to parentheses which are arguably extraneous.

In the presence of simplification, ((MMINUS) 2) simplifies to -2 (i.e. the negative integer), and -2*x is displayed as -2 x.

Closing this report as won't-fix. Thanks for taking the time to make a report, and thanks for your interest in Maxima.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-01 18:05:14 Created by robert_dodier on 2023-02-22 02:21:10 Original: https://sourceforge.net/p/maxima/bugs/3299/#8a91


For the record, the output in this case is now -2*x as expected, since commit ccf37eb6 (increasing the precedence of MMINUS) a few weeks ago.