Doenet / DoenetTools

https://www.doenet.org/
15 stars 29 forks source link

Inconsistent comparison of expressions with equality #1717

Closed dqnykamp closed 1 year ago

dqnykamp commented 1 year ago

For general mathematical expressions, when using the default numerical comparison, different versions of the same equality should be recognized as equal. For example, we get the expected behavior in the following:

<p>True: <boolean><math>a=b</math> = <math>-a=-b</math></boolean></p>
<p>True: <boolean><math>a=b</math> = <math>a-b=0</math></boolean></p>

However, if an expression includes a symbolic function (the symbol "f" is, by default, included in functionSymbols), then such manipulations are incorrectly evaluated as changing the expression:

<p>False, but should be true: <boolean><math>f(a)=b</math> = <math>-f(a)=-b</math></boolean></p>
<p>False, but should be true: <boolean><math>f(a)=b</math> = <math>f(a)-b=0</math></boolean></p>

This discrepancy is probably due to the fact that the numerical evaluator cannot handle symbolic functions, so it falls back to symbolic equality. (The expressions also fail to be equal with symbolicEquality simplifyOnCompare.)

dqnykamp commented 1 year ago

Fixed by #1734