I'm writing an app which translates formulae into executable code. I've been experimenting with fairly obvious optimizations such as factoring (reducing number of multiplications) in order to make the code run faster. Can anyone suggest any other performance-related optimizations that could be performed when translating formulae to code? Thanks.
typically takes about twice as long to execute as the equivalent expression
because floating point division is very slow whereas addition and multiplication are fast.
As well as that there are the obvious things to do like pre-computing constant values, and replacing
with the equivalent expressions
This isn't quite so nonsensical as it may appear: the constants
You could also optimize
I think you'd better leave such optimizations to the compiler. Or do you have evidence that the compiler cannot do justice to your formulas?