Skip to content

Raising a matrix to a high power quickly

Question

What is an efficient way to compute AnA^n for a square matrix AA and large integer nn?

Short answer

Repeated squaring: about 2log⁡2n2\log_2 n matrix multiplications. Write nn in binary, square AA repeatedly and multiply into the result whenever the current bit is 11; each multiply costs O(d3)O(d^3) for a d×dd\times d matrix. Alternatively, if A=PDP−1A=PDP^{-1} is diagonalisable, An=PDnP−1A^n=PD^nP^{-1} needs only scalar powers.

Adapted from Joshi, Denson & Downes, Quant Job Interview Questions and Answers, Q5.6, p.158; question and answer rewritten by SelfMadeQuant.com.

See the hint and the full worked solution in the question bank (free account).

Open the worked solution

Lessons behind this question