EmpowerOperations / babel

Simple math expression parser and evaluator
Apache License 2.0
1 stars 1 forks source link

Math Objectives applying negatives before exponents #4

Open AlejandroEmpower opened 6 years ago

AlejandroEmpower commented 6 years ago

Negatives are getting applied to variables and numbers before exponents which is not in accordance with the laws of BEDMAS

This is problematic because OASIS is outputting mathematically incorrect results

Steps to reproduce

  1. Add two variables x1 & x2 and a single Math Objective. Make it -x1^x2
  2. Head over to Module Setup -> Design Verification and Add the point x1 = 1 & x2 = 2
  3. Evaluate

Result

Groostav commented 6 years ago

this is actually an oddly interesting question, I'm suprised I knew so little about the behaviour of negatives with respect to real number powers

AlejandroEmpower commented 5 years ago

Ran into this problem again but this time as a complaint from Behzad. He didn't realize this was happening but was instead complaining about values he wasn't expecting in massive equations.

Did some debugging and the problem seems to be what this issue entails. He wants the Expected results but was getting the Actual. I however jumped onto Excel to test and found OASIS's way of dealing with the unary negative is inline with Excels. I'm pretty sure Excel is used world-wide so this seems to be a standard, even thought I don't like it.