# HAKMEM “Fast Fibonacci Transform”

As a fun programming exercise I've been playing around with the algorithm in HAKMEM 12 for the representation of Fibonacci and similar recurrence relations. In short, if we define operations on ordered pairs

$$(A, B) * (C, D) = (AC + AD + BC, AC + BD)$$

$$(A, B) + (C, D) = (A + C, B + D)$$

$$k * (A, B) = (kA, kB)$$

$$(A, B)^{-1} = (-A, A + B) * \frac{1}{B^2 + AB - A^2}$$

$$\frac{(A, B)}{(C, D)} = (A, B) * (C, D)^{-1}$$

and let

$$\mathbf 0 = (0, 0)$$

$$\mathbf 1 = (0, 1)$$

$$\mathbf F = (1, 0)$$

then we can define exponentiation using repeated multiplication (or more efficient, using repeated squaring) and $$\mathbf{F}^n = F(n)$$, the nth Fibonacci number. I've done all this and it works fine, including for negative integer powers.

The entry then goes on to suggest that we can go on to use power series and define $$e^x$$ and $$\ln x$$, which will allow computing "fractional" Fibonacci numbers (yes, I know there are other ways to do it, I just want to follow through with the example!). I assume the intent is to use the identity $$a^b = e^{a \ln b}$$ to get fractional powers of $$\mathbf F$$.

I defined $$e^x = \sum_{n=0}^{\infty}{\frac{x^n}{n!}}$$ and it seems to work fine. I defined $$\ln x$$ using the recurrence here, iterating on $$y_{n+1} = y_n + x * e^{-y_n} - 1$$, and that works as far as giving me things like $$\ln \mathbf 1 = \mathbf 0$$, $$\ln e^{\mathbf 1} = \mathbf 1$$, and $$\ln e^{\mathbf F} = \mathbf F$$.

But when I try to define $${\mathbf F}^x$$ for fractional x as $$e^{x \ln \mathbf F}$$ I find that $$\ln \mathbf F$$ diverges. A little bit of plotting seems to suggest that the answer does indeed lie out at infinity somewhere along a line with slope $$-\varphi$$.

Is my work correct? Does $$\ln \mathbf F$$ really not exist? If so, is there another technique or identity I should use to derive the "fractional Fibonaccis" from the tools I have here (e.g. not the Binet formula)?

• It says "power series and Newton's method". Have you tried finding $F^{\frac{1}{2}}$ using $x_0 = \mathbf 1$, $x_n = \frac12 (x_{n-1} + \frac{\mathbf F}{x_{n-1}})$? – Peter Taylor Nov 21 at 22:48
• @PeterTaylor I haven't. I can go down that route but it's less exciting. The calculation of ln is where I'm using Newton :) – hobbs Nov 22 at 1:53
• @PeterTaylor that doesn't converge either, strangely enough. – hobbs Nov 24 at 17:37

The operations you refer to defined on ordered pairs is just one way to refer to arithmetic on algebraic numbers. In the case of Fibonacci, if we define $$\,F\,$$ as a root of the equation $$\, F^2 = F+1,\,$$ and interpret the ordered pair $$\,(A,B)\,$$ as just $$\, A\cdot F+B\,$$ then the operations of $$+$$ and $$*$$ on ordered pairs is exactly that which is induced by the operations of addition and multiplication for the corresponding algebraic numbers. Over the real field, the two solutions to the equation $$\, F^2 = F+1\,$$ are $$\,F = P := (1+\sqrt{5})/2\,$$ and $$\, F = Q := (1-\sqrt{5})/2.\,$$ Thus, the result $$\, \exp(F) \approx 2.014322\cdot F+1.783923\,$$ expresses the two results $$\, \exp(P) \approx 5.043165\,$$ and $$\, \exp(Q) \approx 0.539003\,$$ simultaneously.
So far, so good. What about $$\,\ln(F)?\,$$ We compute $$\,\ln(P) \approx 0.481211\,$$ but, since $$\,Q\,$$ is negative, $$\,\ln(Q) \approx -0.481211 +(2k+1)\pi i\,$$ which is multi-valued. Using the principal value gives $$\,\ln(Q) \approx -0.481211 +\pi i.\,$$ With a bit of linear algebra we get $$\ln(F) \approx (0.430409-1.40496 i)\cdot F +(-0.215204+2.27328 i).$$ The same technique will give you values for $$\,f(F)\,$$ for other functions $$\,f\,$$. For example, we have the formula $$\,F^n = F_n\cdot F + F_{n-1}\,$$ which is equivalent to the Binet formula, as it should be. A special case of this is $$\,F^2 = F + 1\,$$ by the definition of $$\,F.\,$$
Similar results hold for other simple polynomials such as $$\,x^2-1\,$$ resulting in split-complex numbers and $$\,x^2+1\,$$ resulting in the usual complex numbers. However, for $$\,x^2\,$$ the resulting dual numbers are a bit more complicated to explain.