NB. Responding to a request from Raul in Jbeta

NB. A cool use of eigen values and vectors -- recursion


NB. Preliminaries

clean =: * *@|  NB. numbers with 2^_44 > | are replaced by 0

mp =: +/ . *  NB. matrix product

NB. below, square matrix x to integer power y

mpwr =: ( 4 : 'x mp^:y =i.#x' )"2 0


NB. The recursion ( (1+k) { u ) -: A mp k { u where u is a matrix

]A  =: 1 1,.1 0 NB. used for Fibonnaci recursion

]lambda =: 2 %~ (1+%:5),1-%:5  NB. eigenvalues of A

]Lambda =: lambda * =i.# lambda  NB. eigenvalues on diagonal

]S =: 2 2 $ lambda,1 1  NB. columns are eigenvectors

(A mp S) -: lambda *&.|: S  NB. test claimed eigen vectors, values

]u0 =: 1 0  NB. first row of matrix u

]nr =: 7  NB. number of rows in u

]u =: (A mpwr i. nr) mp"2 1 u0  NB. produce matrix u

NB. Rows obey Fibonnaci recursion, observe second column

(}. u) -: }: A mp&.|: u  NB. test "A" recursion in the rows of u

NB. You can produce u using the eigen vectors and values of A:

u -: ( S mp"2 (Lambda mpwr i. nr) mp"2 S mpwr _1 ) mp"2 1 u0

NB. More simply:

c =: (S mpwr _1) mp u0

u -: S mp"2 1 c *"1 lambda^"1 0 i. nr


NB. Above will work if n by n A has n linearly independent eigenvectors.


--Kip Murray

Sent from my iPad

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to