-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsol-1.19.tex
31 lines (31 loc) · 1.13 KB
/
sol-1.19.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
The linear transformation $T_{pq}$ is represented by the matrix
$$
\pmatrix{ p + q & q \cr
q & p }\hbox{,}
$$
therefore its square $T_{pq}^2$ is represented by the matrix
$$
\pmatrix{ p + q & q \cr
q & p }^2 = \pmatrix{ (p^2 + q^2) + (q^2 + 2pq) & q^2 + 2pq \cr
q^2 + 2pq & p^2 + q^2 } = \pmatrix{p' + q' & q' \cr
q' & p' }\hbox{,}
$$
which is also the matrix representing the linear transformation $T_{p'q'}$, with $p' = p^2 + q^2$ and $q' = 2pq + q^2$.
The procedure to compute $\Fib(n)$ becomes
\begtt\scm
(define (fib n)
(fib-iter 1 0 0 1 n))
(define (fib-iter a b p q count)
(cond ((= count 0) b)
((even? count)
(fib-iter a
b
(+ (* p p) (* q q))
(+ (* 2 p q) (* q q))
(/ count 2)))
(else (fib-iter (+ (* b q) (* a q) (* a p))
(+ (* b p) (* a q))
p
q
(- count 1)))))
\endtt