Why it matters
Matrix expo turns huge-n recurrences into fast computation. Essential technique.
Advertisement
The architecture
Encode recurrence as matrix M.
State transitions: v_next = M @ v.
M^n via fast exponentiation.
Advertisement
How it works end to end
Fibonacci matrix: [[1,1],[1,0]]. F_n from M^n.
General linear recurrence: encode all state.
Modular arithmetic for large n.