Skip to content

Simplifying terms

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

Multiplicative terms

Multiplicate terms are determined on a '*' operator after all the children are simplified. Multiplicative terms have a base_ and an exponent_. After all the children have been converted into terms, all terms with the same base_ (determined by printing and comparing their strings) have their exponents added. The terms are then added back to a new multiplicative operator in descending order of their exponents.

Additive terms

Additive terms are determined on a '+' operator after all the children are simplified. Additive terms have a base_ and a coefficient_. After all the children have been converted into terms, all terms with the same base_ have their coefficients added. The terms are then added back to a new addition operator. The terms are currently unsorted.