# Futility Closet, Fibonacci and Quadratic Residues

I love Futility Closet – it’s an incredible collection of interesting bits and pieces, but it has a special place in my heart because *they love and appreciate maths*. Not only that, they appreciate maths that *I* find interesting. The internet has many interesting miscellanies, and many excellent sites specialising in maths, but very few that mix maths up with other stuff. So well done them.

For example, this post set me thinking about whether there’s a simple way to generate Machin-like formulas for $\pi$ using Fibonacci sums? Well, it turns out, not exactly – while $\arctan\br{\frac{1}{1}} = \arctan\br{\frac{1}{2}} + \arctan\br{\frac{1}{3}}$, it’s not the case that $\arctan\br{\frac{1}{2}} = \arctan\br{\frac{1}{3}} + \arctan\br{\frac{1}{5}}$. But what is it? And why?

### Working it out

Suppose I want to find $x$ such that $\arctan\br{x} = \arctan\br{\frac{1}{2}} - \arctan\br{\frac{1}{3}}$. How would I do that? Obviously, there are calculators available, but who wants to use *those*? ((Hi, sensei, didn’t see you come in. Lovely weather we’re having.))

I could apply $\tan$ to both sides to get $x = \tan\br{\arctan\br{\frac{1}{2}} - \arctan\br{\frac{1}{3}}}$, which at first looks preposterous, but bear with me: if we let $A=\arctan\br{\frac{1}{2}}$ and $B=\arctan\br{\frac{1}{3}}$, we can apply our compound angle formulas and state that $x = \frac{\tan(A)-\tan(B)}{1+\tan(A)\tan(B)}$; and we know what $\tan(A)$ and $\tan(B)$ are, they’re $\frac{1}{2}$ and $\frac{1}{3}$, respectively.

This is going to become a mess of fractions, but we can live with that: $x = \frac{\frac{1}{2}-\frac{1}{3}}{1+ \frac{1}{2}\times \frac{1}{3}}$. Now multiply top and bottom by 6 to get $x = \frac{3-2}{6+1} = \frac{1}{7}$.

(We can also generalise a bit here: if $\tan(A) = \frac{1}{a}$ and $\tan(B) = \frac{1}{b}$, we always get $\tan\br{A-B}=\frac{a-b}{ab+1}$.)

### How does that help?

If we wanted to make a Machin-like formula based on this idea, we might start with $\arctan\br{\frac{1}{1}} = \arctan\br{\frac{1}{2}} + \arctan\br{\frac{1}{3}} = \piby{4}$ and say: what happens if we systematically replace the larger fraction? We already know what we can do with the first term - we just worked out $\arctan \br {\frac{1}{2}} = \frac{1}{3} + \frac{1}{7}$.

That makes our identity $ \piby{4} = 2\arctan \br{\frac{1}{3}} + \arctan \br{\frac{1}{7}}$.

What about $\arctan \br{\frac{1}{3}}$? Well, we know we can write it as $\arctan \br{\frac{1}{5}} + \arctan \br{\frac{1}{8}}$, because the article says so, but I like the look of $\arctan \br{ \frac{1}{4}} + \arctan \br{ \frac{1}{13}}$, which comes from the formula before.

Now I’m going to do something I should have done a long time ago: I will now define the function $A(x)$ to be $\arctan\br{\frac{1}{x}}$, mainly to save me some typing.

We’ve got $\piby 4 = 2 \br { A(4) + A(13) } + A(7)$

### Proceed recursively!

We can say $A(4) = A(5) + A(21)$, giving us $\piby 4 = 2 A(5) + A(7) + 2A(13) + 2A(21)$.

Then $A(5) = A(6) + A(31)$, so we have $\piby4 = 2A(6) + A(7) + 2A(13) + 2A(21) + 2A(31)$.

Lastly for now, $A(6) = A(7) + A(43)$, giving $\piby4 = 3A(7) + 2A(13) + 2A(21) + 2A(31) + 2A(43)$.

The further along we go, the more elements we will have in the right-hand side, but - when applying the Gregory-Leibniz formula ((discovered by Madhava of Sangamagrama)) (which is really a Maclaurin series ((as first published by Taylor)) ), $\arctan(x) = x + \frac{1}{3}x^3 + \frac{1}{5}x^5 + …$, we need fewer and fewer terms in each sequence for it to converge to a nice answer.

### Could we be smarter about how we pick the terms?

I’ve been fairly careless about how I picked the next number in each case - picking ‘the next integer’ does always guarantee a unit fraction in the next phase, but we can do better.

For example, $A(x) - A(x+2)$ works out to be $A\br{\frac{2}{(x+1)^2}}$ – and $x+1$ is even if $x$ is odd. So, whenever we have an odd $x$ as our biggest term, we can pick the next integer to be *two* bigger rather than 1.

This can be extended WAY further! With a great deal of work, you can find that you can jump a distance of $n$as long as $x^2 = -1 \pmod {n}$- which happens surprisingly often!

Since the Fibonacci numbers satisfy $F(n)F(n+2) = F(n+1)^2 \pm 1$, with the sign alternating – the curiosity given by Futility Closet works!