I'm trying to find a closed form solution to the sequence
$a_{n+1}=\frac{a_{n}}{2} + \frac{5}{a_{n}}$
I tried using a generating function approach in the following way:
Let $$f(x) = \sum_{n=1}^\infty a_n x^n$$ Then multiplying the original equation with $x^n$ and summing over all $n$, we get:
$$\sum_{n=1}^\infty a_{n+1}x^n= \sum_{n=1}^\infty \frac{a_{n}}{2} x^n + \sum_{n=1}^\infty\frac{5}{a_{n}} x^n$$ $$= \frac{f(x) - a_1}{x} = \frac{f(x)}{2} + 5 \sum_{n=1}^\infty \frac{x^n}{a_n}$$ But now I don't know how to simplify the last term and I get stuck. I put it on Wolframalpha and found the general solution to the recurrence relation as: $$a_n = -i \sqrt{10} \cot\left(c_1 2^n\right)$$
Here is an intuition: Rewrite the recurrence relation s
$$ a_{n+1} = \frac{1}{2}\left(a_n + \frac{\ell^2}{a_n}\right), \qquad \ell = \sqrt{10}. $$
This is precisely what we get when we apply the Newton-Raphson method to $x^2 - \ell^2$. So,
This naturally leads us to study the behavior of the sequences $(x_n^+)$ and $(x_n^-)$ defined by
$$ x_n^{\pm} = a_n \pm \ell. $$
Let us find the recurrence relation for these sequences:
$$ x_{n+1}^{\pm} = a_{n+1} \pm \ell = \frac{1}{2}\left(a_n + \frac{\ell^2}{a_n}\right) \pm \ell = \frac{(a_n \pm \ell)^2}{2a_n} = \frac{(x_n^{\pm})^2}{2a_n}. $$
This gives an intuitive explanation to @NN2's wonderful trick. Indeed, taking ratio of the two sequences,
$$ \frac{x_{n+1}^+}{x_{n+1}^-} = \left( \frac{x_{n}^+}{x_{n}^-} \right)^2, \qquad\text{i.e.,}\qquad \frac{a_{n+1} + \ell}{a_{n+1} - \ell} = \left( \frac{a_n + \ell}{a_n - \ell} \right)^2. $$
Iterating this, we get
$$ \frac{a_n + \ell}{a_n - \ell} = \left( \frac{a_0 + \ell}{a_0 - \ell} \right)^{2^n}. $$
Now solving this for $a_n$ gives the desired recurrence relation for $(a_n)$.