rtoy / maxima

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

Too many parens in (- 2 (y.x)) + y + 1 #1120

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 00:42:14 Created by macrakis on 2015-12-30 23:22:13 Original: https://sourceforge.net/p/maxima/bugs/3063


set dotscrules:dotconstrules:true to ensure that the scalar factors are pulled out.

-y.x displays as -y.x, as expected 2*y.x displays as 2 (y.x) string(2*y.x) => 2*y . x without parentheses -y.x + y displays as y-y.x -- note no parentheses (with default negsumdisplag=true) -y.x+y+1 displays as (- y . x) + y + 1 instead of simply - y . x + y + 1 -2*y.x+y+1 displays as (- 2 (y . x)) + y + 1 -- this is surely wrong string(-2*y.x+y+1) => (-2*y . x)+y+1 -- why parentheses at all? string( 2*y.x+y+1) => 2*y . x +y+1 -- no parentheses

string output is supposed to be re-readable, so you'd expect it to be more cautious than display, but in fact it is display that is adding superfluous parentheses

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 00:42:15 Created by robert_dodier on 2016-01-04 01:06:05 Original: https://sourceforge.net/p/maxima/bugs/3063/#d13a


Diff:


--- old
+++ new
@@ -1,12 +1,12 @@
 set dotscrules:dotconstrules:true to ensure that the scalar factors are pulled out.

--y.x displays as -y.x, as expected
-2*y.x displays as 2 (y.x)
-     string(2*y.x) => 2*y . x without parentheses
--y.x + y displays as y-y.x -- note no parentheses (with default negsumdisplag=true)
--y.x+y+1 displays as (- y . x) + y + 1 instead of simply - y . x + y + 1
--2*y.x+y+1 displays as (- 2 (y . x)) + y + 1 -- this is surely wrong
-    string(-2*y.x+y+1) => (-2*y . x)+y+1  -- why parentheses at all?
-    string( 2*y.x+y+1) =>  2*y . x +y+1  -- no parentheses
+`-y.x` displays as `-y.x`, as expected
+`2*y.x` displays as `2 (y.x)`
+    `string(2*y.x)` => `2*y . x` without parentheses
+`-y.x + y` displays as `y-y.x` -- note no parentheses (with default negsumdisplag=true)
+`-y.x+y+1` displays as `(- y . x) + y + 1` instead of simply `- y . x + y + 1`
+`-2*y.x+y+1` displays as `(- 2 (y . x)) + y + 1` -- this is surely wrong
+    `string(-2*y.x+y+1)` => `(-2*y . x)+y+1`  -- why parentheses at all?
+    `string( 2*y.x+y+1)` =>  `2*y . x +y+1`  -- no parentheses

 string output is supposed to be re-readable, so you'd expect it to be *more* cautious than display, but in fact it is display that is adding superfluous parentheses