jiggzson / nerdamer

a symbolic math expression evaluator for javascript
http://www.nerdamer.com
MIT License
517 stars 82 forks source link

Test Truth of Equality #602

Closed Ephraim-Bryski closed 3 years ago

Ephraim-Bryski commented 3 years ago

I would like to test if an equality containing variables is necessarily true. For example a*b=b*a would return true, while a=b would return false (not necessarily true)

(Of course, exactly what it returns isn't important, just some way of distinguishing).

Is this possible to do currently? Could it be implemented in Nerdamer? Thank you!

jiggzson commented 3 years ago

@Ephraim-Bryski, would something like this work?

console.log(nerdamer('a*b').eq('b*a')); // true
console.log(nerdamer('a-b').eq('b-a')); // false

nerdamer.setVar('x',3);
console.log(nerdamer('x+a').eq('a+3')); // true

You can find the remaining operations here under Expression > Equality.

Ephraim-Bryski commented 3 years ago

Thank you, that's exactly what I was looking for.