Summer 2024 · CS691-XVIII · Applications of Linear Algebra
Course Project loosely based on Miniature 1 and 2 from the book “Thirty-three Miniatures: Mathematical and Algorithmic Applications of Linear Algebra” by Jiřì Matoušek
By Sourabh Warrier & Cherian George
Consider the following sequence,
Sn=a1Sn−k+a2Sn−k+1+...+akSn−1∋ai∈R
Any term is a linear combination of the previous k terms and first k terms S1 to Sk are given by the base cases b1 to bk of the recursion. Given a set of k terms in such a sequence, the process of obtaining subsequent terms can be represented as linear transformation of vectors in Rk. Consider the following vectors,
v0=⎣⎢⎢⎢⎢⎢⎢⎡Si+k−1Si+k−2...Si⎦⎥⎥⎥⎥⎥⎥⎤ and v1=⎣⎢⎢⎢⎢⎢⎢⎡Si+kSi+k−1...Si+1⎦⎥⎥⎥⎥⎥⎥⎤∋v1=Av0, where A is a linear transformation. The entries of A would depend on the coefficients a1 to ak specific to the sequence. In this case A=⎣⎢⎢⎢⎢⎢⎢⎢⎢⎡ak1...00ak−1.........ak−2010...001a1000⎦⎥⎥⎥⎥⎥⎥⎥⎥⎤
Eigenbasis of A
The eigenvalues of A are the roots of the polynomial P(λ)=∣A−λI∣=0. Suppose by some means, eigenvalues λ1 to λk and their corresponding eigenvectors ϕ1 to ϕk could be obtained. The transformation A can be written as PDP−1, where P=[ϕ1ϕ2...ϕk] and D=⎣⎢⎢⎢⎢⎢⎢⎡λ10...00λ20.........00λk⎦⎥⎥⎥⎥⎥⎥⎤. This gives us vn=Anv0=PDnP−1v0.
Examples
{Sn=Sn−2+Sn−1,{S1=S2=1}}
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …
The first example we’ll look at is the Fibonacci sequence (OEIS \href{https://oeis.org/A000045}{A000045}). From the definition, we have a1=a2=1 and S1=S2=1. Therefore, A=[1110], v0=[11] and P(λ)=∣A−λI=0∣⟹λ2−λ−1=0, giving us λ1=21+5 and λ2=21−5. With the augmented matrix
[1−λ11−λ00], written in REF as
[1−λ011−λλ2−λ−100]⟹ϕ=[1λ−1]. Plugging in λ1 and λ2 we find that ϕ1=[1λ1−1] and ϕ2=[1λ2−1]. Here, P=[1λ1−11λ2−1], D=[λ100λ2] and P−1=λ2−λ11[λ2−11−λ1−11]. Since vn=Anv0=PDnP−1v0, we look at the first coordinate of PDn−2P−1v0 to obtain the nth term of the sequence. This gives us [SnSn−1]=λ2−λ11[1λ1−11λ2−1][λ1n−200λ2n−2][λ2−11−λ1−11][11]=λ2−λ11[λ1n−2(λ2−2)+λ2n−2(2−λ1)λ1n−2(λ1−1)(λ2−2)+λ2n−2(λ2−1)(2−λ1)]. Extracting Sn, from where Sn=λ2−λ11(λ1n−2(λ2−2)+λ2n−2(2−λ1))=λ1−λ21(λ1n−2(λ1+1)−λ2n−2(λ2+1)){∵λ2=1−λ1}. Since from the characteristic equation, λ+1=λ2, this simplifies to λ1−λ21(λ1n−λ2n). Plugging in the values of λ1 and λ2 produces
Sn=51(21+5)n−51(21−5)n
{Sn=Sn−2+2Sn−1,{S1=S2=1}}
1,1,3,7,17,41,99,239,577,1393,...
This is sequence \href{https://oeis.org/A001333}{A001333} in the OEIS. Each term is the sum of twice the previous term and once the term before that. The base cases are identical to that of the Fibonacci sequence. The transformation for this sequence is A=[2110] and the characteristic polynomial λ2−2λ−1=0. The eigenvalues and eigenvectors of A are λ1=22+8, λ2=22−8, ϕ1=[1λ1−2] and ϕ2=[1λ2−2].
P=[1λ1−21λ2−2], D=[λ100λ2] and P−1=λ2−λ11[λ2−22−λ1−11] and
[SnSn−1]=λ2−λ11[1λ1−21λ2−2][λ1n−200λ2n−2][λ2−22−λ1−11][11]⟹Sn=λ2−λ11(λ1n−2(λ2−3)+λ2n−2(3−λ1))=λ1−λ21(λ1n−2(3−λ2)−λ2n−2(3−λ1)), which simplifies to the formula
Sn=2+81(1+2)n+2−81(1−2)n
{General solution for k = 2}
Sn=a1Sn−2+a2Sn−1,{S1=b1,S2=b2}
In the general case when the nth term is a linear combination of the previous two terms with coefficients a1 and a2 and base cases b1 and b2, we represent the corresponding transformation by A=[a21a10]. The eigenvalues of A are obtained by solving λ2−a2λ−a1=0, from where λ1=2a2+a22+4a1 and λ2=2a2−a22+4a1. Solving [a2−λ1a1−λ00]⇝[a2−λ0a1a2−λλ2−a2λ−a100]⟹ϕ1=[1a1λ1−a2] and ϕ2=[1a1λ2−a2]. P=[1a1λ1−a21a1λ2−a2], D=[λ100λ2], and P−1=λ2−λ1a1[a1λ2−a2a1a2−λ1−11]. We obtain vn−2 from the expression
[SnSn−1]=λ2−λ1a1[1a1λ1−a21a1λ2−a2][λ1n−200λ2n−2][a1λ2−a2a1a2−λ1−11][b2b1],
from where Sn=λ2−λ1a1(λ1n−2(a1b2(λ2−a2)−b1)+λ2n−2(a1b2(a2−λ1)+b1))
=λ1−λ21(λ1n−2(a1b1+b2λ1)−λ2n−2(a1b1+b2λ2)). This produces the following formula
TBC…