Re: [sympy] Precedence of negation

2021-03-25 Thread Paul Royik
You examples would work even if precedence of negation equals precedence of Mul. And PRECEDENE['Add'] doesn't work for Unevaluated(-x)*y. It will output (-x)*y. Negation is just a Mul. On Thursday, March 25, 2021 at 9:55:06 AM UTC+2 asme...@gmail.com wrote: > The precedence in the printers is

Re: [sympy] Precedence of negation

2021-03-25 Thread Aaron Meurer
The precedence in the printers is just about where it needs to add parentheses. I suppose negation is the same as Add because it doesn't require parentheses for anything with a higher precedence. For instance -x*y is fine rather than -(x*y), but -(x + y) requires the parentheses. Aaron Meurer On

Re: [sympy] Precedence of negation

2021-03-25 Thread Paul Royik
from sympy.printing.precedence, PRECEDENCE precedence(-x) == PRECEDENCE['Add'] It gives True. On Wednesday, March 24, 2021 at 10:36:52 PM UTC+2 asme...@gmail.com wrote: > Can you clarify what you mean by this? > > The precedence of operators in Python is determined by the language. > See >

Re: [sympy] Precedence of negation

2021-03-24 Thread Aaron Meurer
Can you clarify what you mean by this? The precedence of operators in Python is determined by the language. See https://docs.python.org/3/reference/expressions.html#operator-precedence. Unary - has a higher precedence than binary + (or binary -). In SymPy, -x is represented as (-1)*x, but this

[sympy] Precedence of negation

2021-03-24 Thread Paul Royik
Is there any reason why precedence of -x equals precedence of Add? -x is (-1)*x -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To