Simplifying Expressions

Feb 28, 2010 at 12:27 AM

Hi.

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.

Thanks

Regards

daniela da cruz

Coordinator
Feb 28, 2010 at 11:54 AM

Optimizer is placed in:

ILCalc\Others\Optimizer\OptimizeOutput.cs

Feb 28, 2010 at 2: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.

thanks

Coordinator
Feb 28, 2010 at 2: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 3:08 PM

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

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

thanks