# Generating function for squared fibonacci numbers

We know that generating function for fibonacci numbers is $$B(x)=\frac{x}{1-x-x^2}$$

How can we calculate $B(x)^2$? I thought that, if we have $B(x)=F_n*x^n$ then $$B(x)*B(x) = \sum_{n=0}^\infty (\sum_{i=0}^n F_iF_{n-i})x^n$$

And $$B(x)^2 = (\frac{x}{1-x-x^2})^2$$, but it's not true, because according to oeis, generating function for this is $$\frac{x(1-x)}{(1+x)(1-3x+x^2)}$$

I'd really appreciate some help on this

• The g.f. for the square of a sequence is not the square of the g.f. for the sequence. $B(x)^2$ does not represent the sequence $F_n^2$. – vadim123 Mar 16 '14 at 20:13
• What is strange is that the question gives the correct formula for $B(x)^2$, showing clearing that it is the generating function for $\sum_{i=0}^n F_i F_{n-i}$, not $F_n^2$. – Slade Mar 16 '14 at 20:27
• The first half of the question is true, but applies to the square of the generating function of the Fibonacci sequence, not the generating function of the squares of the sequence as in the title, that is, $\sum_{n=1}^{\infty}F_n^2\,x^n$. – Dr. Lutz Lehmann Mar 16 '14 at 20:58

Use two consecutive Leonardo (da Pisa, called Fibonacci) recursion equations \begin{align} F_{n+2}&=F_{n+1}+F_{n}\\ F_{n-1}&=F_{n+1}-F_n \end{align} square them and add them \begin{align} F_{n+2}^2&=F_{n+1}^2+F_{n}^2+2F_{n+1}F_{n}\\ F_{n-1}^2&=F_{n+1}^2+F_n^2-2F_{n+1}F_n\\[0.3em]\hline F_{n+2}^2+F_{n-1}^2&=2F_{n+1}^2+2F_n^2 \end{align} Now find the generating function for this recursion formula.

• Thanks for your answer, but i'm curious... how does this work, how did you get it? Would love to see some hints or longer notes about it. Thanks – Krzysztof Lewko Mar 16 '14 at 20:07
• You need a recursion for the squares. So square the Fibonacci equation. But then there is the mixed term. So look for another Fibonacci recursion equation that contains $F_{n+1}$ and $F_n$. Well, that would be just $F_{n+1}=F_n+F_{n-1}$. Regroup to obtain the correct mixed term while squaring, and then cancel the mixed term. – Dr. Lutz Lehmann Mar 16 '14 at 20:11
• Great, thank you, that's very smart, cause i was stuck with this $F_{n-1}F_{n-2}$ – Krzysztof Lewko Mar 16 '14 at 20:21
• If it's not a problem. Why can we say that $F_n^2 = 2F_{n-1}^2 + 2F_{n-2}^2-F_{n-3}^2$ is equivalent to $F_n = 2F_{n-1} + 2F_{n-2}-F_{n-3}$ ? – Krzysztof Lewko Mar 16 '14 at 20:49
• Why should that be true? $F_n=2F_{n-2}+F_{n-3}$ or $F_n=2F_{n-1}-F_{n-3}$ does contradict your second equation. But set $Q_n=F_n^2$ for "quadratus", then $Q_n=2Q_{n−1}+2Q_{n−2}−Q_{n−3}$. – Dr. Lutz Lehmann Mar 16 '14 at 20:54

Note that generating functions are not usually a good tool for studying the square of a sequence, since there is no general relationship between the generating function of $a_n$ and the generating function of $a_n^2$.

Here is an approach that I like:

Let $\tau$ and $\overline{\tau}$ be the positive and negative roots, respectively, of the equation $z^2-z-1=0$. In other words, we have $1-x-x^2 = (1-\tau x)(1-\overline{\tau} x)$. Then we can write the Fibonacci numbers as $$F_n = \frac{\tau^n-\overline{\tau}^n}{\tau-\overline{\tau}} =\frac{1}{\sqrt{5}} (\tau^n-\overline{\tau}^n)$$. We can convert this formula to and from the generating function form using partial fractions.

It's also useful to have another sequence handy, the Lucas sequence $L_n$, which has $L_0=2$, $L_1=1$, and satisfies the same recursion as $F_n$. It has generating function $A(x)=\frac{2-x}{1-x-x^2}$, and closed form $$L_n = \tau^n+\overline{\tau}^n$$

With this sequence in mind, we can do calculations involving Fibonacci numbers very quickly and mechanically (note that $\tau \overline{\tau}=-1$): $$F_n^2 = \frac{1}{5}(\tau^{2n} -2\tau^n \overline{\tau}^n+\overline{\tau}^{2n}) = \frac{1}{5}(\tau^{2n} + \overline{\tau}^{2n} -2(\tau \overline{\tau})^n) = \frac{L_{2n}-2(-1)^n}{5}$$

If we want to, we can get the generating function directly from this formula. The generating function for $(-1)^n$ is easily seen to be $\frac{1}{1+x}$. I already mentioned the generating function $A(x)$ for $L_n$, but to get the generating function for $L_{2n}$, we must calculate $\frac{1}{2} (A(\sqrt{x})+A(-\sqrt{x}))$. It follows that this is the generating function of $F_n^2$:

$$\frac{1}{10}(\frac{2-\sqrt{x}}{1-\sqrt{x}-x}+\frac{2+\sqrt{x}}{1+\sqrt{x}-x}-\frac{4}{1+x}) = \frac{x(1-x)}{(1+x)(1-3x+x^2)}$$