Skip to content

Matrix Exponentiation for Linear Recurrences

Coming Soon

This page is under construction. Content will cover the full matrix exponentiation technique for solving linear recurrences in \(O(k^3 \log n)\) time.

What This Page Will Cover

  • The core idea: Any linear recurrence \(F(n) = a_1 F(n-1) + a_2 F(n-2) + \ldots + a_k F(n-k)\) can be expressed as a matrix multiplication
  • Building the transformation matrix: How to convert a recurrence into a \(k \times k\) matrix
  • Fast exponentiation: Computing \(M^n\) in \(O(k^3 \log n)\) using repeated squaring
  • Beyond Fibonacci: Handling recurrences with constant terms, multiple coupled sequences, and non-homogeneous relations
  • When to use it: Problems where \(n\) can be \(10^9\) or larger but the recurrence has a small, fixed number of terms

Prerequisites

  • Logical Recursion — understanding linear recurrences and the fast doubling trick
  • Basic matrix multiplication