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.
Tell me more
×
Mathematics Stack Exchange is a question and answer site for
people studying math at any level and professionals in related fields. It's 100% free, no registration required.
|
|
The code
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? |
|||||||||||||||
|
