Possible Duplicate:
automatically calculate string mathematical expressing in C#
Could someone point me towards some resources which describe in detail how to simplify simple algebraic equations such as "5x+(2x*6x)+2" which should result in "12x^2+5x+2" the operators I need to handle are "+","-","*","/","^" and parenthesis. So far I have implemented a parser and evaluator for numeric terms which converts from in-fix to post-fix and then evaluates.
If someone could give me a basic run-down on how I could accomplish this it would be greatly appreciated.
if you already have a tree internally that represents the equation, you can recursively visit each node to figure out if there's a way to combine the terms of the two sub-nodes. Think about what you would do at each node, then think about boundary conditions (node is null, node has no children, etc.).
Here is how I would approach it:
That's a start. I think