I'm currently working on a modified version of the Shunting Yard Algorithm that would work with variables, but I cant figure out how to get it to work. For example, I would want the algorithm to re-write 2 * (2x + 5) - 5 to 4x + 5. Any ideas / links to already implemented algorithms that does this already?
2 * (2x + 5) - 5
2 * (2*x + 5) - 5
2 2 x * 5 + * 5 -
(Each character could be seen as an element of an array).
-
/ \
* 5
/ \
2 +
/ \
* 5
/ \
2 x
5. Define and apply algebraic rules to the tree. For example, a rule to be able to 'multiply' the 2
node with the 2 * x + 5
subtree.