Skip to main content

Strength reduction

Strength reduction is a program optimization technique that replaces more expensive operations with cheaper ones.

A few examples of strength reduction:

Expensive operationCheaper operation
Division by a power of 2a / 2**na >> n
Modulo by a power of 2a % 2**na & (2**n - 1)
Replacement of powpow(a, 0.5)sqrt(a)
pow(a, 1.5)a * sqrt(a)
pow(a, -1.5)1.0 / (a * sqrt(a))