So I've written this parser program that will parse text containing an expression in infix notation and put it into a tree structure that resembles polish notation.
So, my program converts this:
6x+sin(2x+3)/(x^4-5)
into this:
+
*
6
x
/
sin
+
*
2
x
3
-
^
x
4
5
My question is this: how can I implement an algorithm to simplify the expression in the tree? For example
2+x+3 would evaluate to x+5
2x+6x would evaluate to 8x
I've looked all over the internet for algorithms to do this and such. I don't want to take the time to look through a huge open source program, and all the books on amazon that cover this stuff are over fifty bucks. Does anyone have any experience in this?