Skip to content

Simplification

Adam Dernis edited this page May 24, 2020 · 3 revisions

In calc, simplification is a recursive operation through the tree. Each operator node does its best to simplify itself and then returns the result.

Sample: 4*5+2*3

This is incredibly simple when everything is numerical, but gets far more complicated once you add variables into the expression (pun intended). Calc solves this with additive terms and multiplicative terms.

Simplifying terms

Parenthesis complicate things too, however a few tricks handle them. When a parenthesis simplifies, the parenthesis checks if its parent has a higher than or equal (>=) priority to its child_. If that condition is met, the parenthesis are unnecessary. If that condition is not met, the parent operator is either a '*' or a '^'. These operators can follow the distributive property, so the parenthesis are taken care of like that.

Clone this wiki locally