Exponentiation by squaring computes a large integer or modular power, such as a raised to the power n, in O(log n) multiplications rather than the n minus one multiplications a naive repeated-multiplication approach would require, by repeatedly squaring the base and multiplying the accumulated result by the current squared value whenever the corresponding bit of the exponent's binary representation is set. When performed with a modulus applied after each multiplication, the same technique is the standard method for fast modular exponentiation used throughout public-key cryptography, including RSA. The method has been known in various forms since antiquity and is sometimes called binary exponentiation or square-and-multiply.
Facts
Time Complexity
Time Complexity (category)Logarithmic Time -- O(log n) 1 Time ComplexityO(log n) multiplications 1 Connections
In Field
Source Wikipedia: Exponentiation by squaring
Uses Design Technique
Source Wikipedia: Exponentiation by squaring
Sources
1. Wikipedia: Exponentiation by squaring
Recursive version
This logarithmic number of operations
Uses Design Technique: Recursion, Article body
It follows that the number of recursive calls is ⌈ log 2 n ⌉ , {\displaystyle \lceil \log _{2}n\rceil ,} the number of bits of the binary representation of n.
In Field: Algorithms and Complexity Theory, Lead sentence
exponentiating by squaring is a general method for fast computation of large positive integer powers of a number, or more generally of an element of a semigroup, like a polynomial or a square matrix.
View the SourceReader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.
Sign in to dispute this or suggest a correction.