Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!mach1!torn!howland.reston.ans.net!wupost!uunet!s5!hui
From: hui@fid.morgan.com (Roger Hui)
Subject: Re: Nth power of 2 by 2
Message-ID: <1993Apr24.165250.10899@fid.morgan.com>
Organization: Morgan Stanley & Co., New York, NY
Date: Sat, 24 Apr 1993 16:52:50 GMT
Lines: 30

Emmett McLean wrote on 1994-04-15 re computing the n-th power
of a 2 by 2 matrix.  The solution presented,

   M&(+/ .*) ^: (n-1) M

is rather unsatisfactory in using n-1 rather than n as 
an argument to ^: .

   id  =. ,~ $ {.&1@>:
   pow =. '' : 'x.&(+/ .*) ^: y. id#x.'

   M =. 2 2$1 1 1 0
   M
1 1
1 0
  
   M pow 11        M pow 0           M pow 1          M pow _1
144 89          1 0               1 1              0  1
 89 55          0 1               1 0              1 _1

   M pow _11       (M pow 11) +/ .* M pow _11         +/ .*/ M pow 11 _11
_55   89        1 0                                1 0
 89 _144        0 1                                0 1

   M =. <:/~i.4
   M               M pow 5           M pow _1
1 1 1 1         1 5 15 35         1 _1  0  0
0 1 1 1         0 1  5 15         0  1 _1  0
0 0 1 1         0 0  1  5         0  0  1 _1
0 0 0 1         0 0  0  1         0  0  0  1
