Closed jolyonb closed 6 years ago
The bug is that calc.py
interprets 2^-2^2
as 2^(-2)^2 = 16
, whereas it seems standard (Google, Mathematica, Python) interpret to interpret as 2^-(2^2) = 1/16
. EdX display also suggests should be interpretted as 2^-(2^2)
:
evaluator('2^-2^2', {'x':2}, {}, {}) # 16, same as 2^(-2)^2
Note that this only happens with numerical nested exponents with a negative sign in the exponent... so that's probably pretty rare.
It does NOT happen with symbolic exponents because the parser requires parentheses:
evaluator('2^(-x^2)', {'x':2}, {}, {}) # 1/16
evaluator('2^-x^2', {'x':2}, {}, {}) # raises InvalidInput
Ok, good to have this documented. I looked at calc.py to see why this is happening... and it's baked somewhat strongly into the tree parser. We'd have to refactor that algorithm significantly :-(
Resolved by #59
There is an issue with calc.py whereby exponentiation doesn't parse in the correct order. I can't remember exactly what the issue is, but I remember that we haven't fixed it.