Simplifying Expressions

Feb 27, 2010 at 11:27 PM


I was reading the intro of your library and it says:

Constants folding: 2^8 + x/(6+3+x) became 256 + x/(9+x)

Which piece of code will do this? I'm looking for an expression simplifier. Not an evaluator.



daniela da cruz

Feb 28, 2010 at 10:54 AM

Optimizer is placed in:


Feb 28, 2010 at 1:27 PM

Thanks for your fast reply. Can you help me how to use such class? Because I got several errors when trying to use it.


Feb 28, 2010 at 1:48 PM

This class is not designed to be easily used not by ILCalc itself...


Are you want to get the textual representation of simplified expression?

If yes - it is hard to do so, because after parsing, for example, expression "(2 + 2) * x" is converted into ILCalc's internal representation: [2][2][+][x][*] and optimization works on the same level and outputs [4][x][*]... So needed to write backward converter to get back to the normal infix notation, ILCalc has no such built-in...

If this is what you want, it's better to use other parsers/evaluators, which uses other expression representation - trees. Trees are much easier to optimize and convert back to the textual infix representation... ILCalc is designed for performance in cost of extensibility and flexibility, so optimizer's code is not easy to understand and use outside...

Feb 28, 2010 at 2:08 PM

Yes, was to get a textual representation of simplified expression.

Thanks anyway for your help. Your library is very interesting.