Strength Reduction - Induction Variable (orphan)

Induction Variable (orphan)

Induction variable or recursive strength reduction replaces a function of some systematically changing variable with a simpler calculation 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. For example,

f x = ... (2 ** x) ... (f (x + 1)) ...

becomes

f x = f' x 1 where f' x z = ... z ... (f' (x + 1) (2 * z)) ...

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'.

Read more about this topic:  Strength Reduction

Famous quotes containing the words induction and/or variable:

    They relieve and recommend each other, and the sanity of society is a balance of a thousand insanities. She punishes abstractionists, and will only forgive an induction which is rare and casual.
    Ralph Waldo Emerson (1803–1882)

    There is not so variable a thing in nature as a lady’s head-dress.
    Joseph Addison (1672–1719)