TITLE: An infinite fraction
QUESTION [5 upvotes]: Here's a problem I saw on the AoPS twitter. I thought I might as well post it so that it could be discussed and a solution recorded. 
What is the value of the following?
$$\cfrac{4}{{1 + \cfrac{1^2}{2 + \cfrac{3^2}{2 + \cfrac{5^2}{2 + \cfrac{7^2}{2 +  \cfrac{9^2}{\ddots} }}}}}}$$
As an aside, I find it cool that it can be compressed to the size of a tweet. The actual tweet is just this single line of symbols and nothing more:
$$4 / (1 + (1^2/(2 + 3^2/(2 + 5^2/(2 + 7^2/(2 + 9^2/(2 + ... ) ) ) ) ) ) ).$$

REPLY [6 votes]: $$\arctan(x) = \cfrac{x}{1+\cfrac{1^2x^2}{3-x^2+\cfrac{3^2x^2}{5-3x^2+\cfrac{5^2x^2}{7-5x^2 + \cfrac{7^2x^2}{9-7x^2 + \ddots}}}}}$$
Take $x=1$ to get what you want.

EDIT
The proof for the above is the observation that if
$$S_n = a_1 + a_1 a_2 + a_1 a_2a_3 + a_1 a_2 a_3 a_4 + \cdots + (a_1 a_2 \cdots a_n)$$ then
$$S_n = \cfrac{a_1}{1-\cfrac{a_2}{1+a_2 - \cfrac{a_3}{1+a_3 - \cfrac{a_4}{1+a_4 - \ddots \cfrac{a_n}{1+a_n}}}}}$$where the last term ends as $1+a_n$. Hence sending $n \to \infty$, we get that if
$$S = a_1 + a_1 a_2 + a_1 a_2a_3 + a_1 a_2 a_3 a_4 + \cdots + (a_1 a_2 \cdots a_n) + \cdots,$$ then
$$S = \cfrac{a_1}{1-\cfrac{a_2}{1+a_2 - \cfrac{a_3}{1+a_3 - \cfrac{a_4}{1+a_4 - \ddots}}}}$$
Now we know that
$$\arctan(x) = x - \dfrac{x^3}3 + \dfrac{x^5}5 = \cdots$$
Set $a_1 = x$, $a_2 = -\dfrac{x^2}3$, $a_3 = -\dfrac{3x^2}5$ and in general $a_n = - \dfrac{(2n-3)x^2}{2n-1}$ to get what we want.