Finding $a_n$ for $a_{n+1}=\frac{1}{2}\left(a_n+\frac{1}{a_n}\right)(n=1,2,3,\cdots),~a_1=2$ I would appreciate if somebody could help me with the following problem: 
Q: find $a_n=?$
$$a_{n+1}=\frac{1}{2}\left(a_n+\frac{1}{a_n}\right)(n=1,2,3,\cdots),~a_1=2$$
There are quite a few posts on the main site concerning convergence of this sequence, for example, Calculating square roots using the recurrence $x_{n+1} = \frac12 \left(x_n + \frac2{x_n}\right)$ and more generally Calculating square roots using the recurrence $x_{n+1} = \frac12 \left(x_n + \frac2{x_n}\right)$. So from those posts we know that it converges to $\sqrt2$. But finding the $n$-th term is a slightly different task from finding the limit.

Rewrite $a_n$ as $\frac{p_n}{q_n}$ for two sequences $p_n, q_n$ that need to be determined.
We have: 
$$a_{n+1} = \frac12 ( a_n + \frac{1}{a_n} ) \iff \frac{p_{n+1}}{q_{n+1}} = \frac{p_n^2+q_n^2}{2p_nq_n}$$
We can choose $p_{n+1} = p_n^2 + q_n^2$ and $q_{n+1} = 2p_nq_n$ and get:
$$ p_{n+1} \pm q_{n+1} = ( p_n \pm q_n )^2 \implies p_{n} \pm q_{n} = (p_1 \pm q_1)^{2^{n-1}}$$
Since $a_1 = 2$, we take $p_1 = 2, q_1 = 1$ to get:
$$ p_{n} + q_{n} = 3^{2^{n-1}} \text{ and } p_{n} - q_{n} = 1$$
This leads to
$$ a_{n} = \frac{p_n}{q_n} = \frac{3^{2^{n-1}}+1}{3^{2^{n-1}}-1}$$
