| |||||||||
Strength reduction is a software optimisation where a function of some systematically changing variable is calculated more efficiently by using previous values of the function. In a procedural programming language this would apply to an expression involving a loop variable and in a declarative language it would apply to the argument of a recursive function. E.g.
becomes
where
Here the expensive operation (2**x) has been replaced by the cheaper 2*z in the recursive function f'. This maintains the invariant that z = 2**x for any call to f'.
See also: Compiler optimization
This article was originally based on material from the Free On-line Dictionary of Computing and is used under the GFDL.