Note Since a more general answer has been given to the initial problem by @Renji Rodrigo, I decided to improve the post in other to avoid future duplicate regarding such question like here

Question what is the closed form of the sequence $(a_n)_n$ with following recursive relation? $$\color{blue}{u_{n+1}=a_nu_n+b_n~~~\text{where $a_1$, $a_n$ and $b_n$ are given.}}$$

Initial question

The initial question was just the particular case of the aforementioned general question. Namely Let $a_2 = 2$ and $b_2= -\frac{1}{2}$ and consider $$a_{n+1} =a_n\frac{n-1}{n+1}+\frac{2}{n+1}~~~and~~~~b_{n+1} =b_n\frac{n-1}{n+1}~~n\ge 2$$ I would like to fine the closed form of $a_n$ and $b_n$

So far By telescopic product I was able to get the formula for $b_n$, as follows

$$\frac{b_{n+1}}{b_2}=\prod^{n}_{k=2}\frac{b_{k+1}}{b_k}=\prod^{n}_{k=2}\frac{k-1}{k+1}=\prod^{n}_{k=2}\frac{k-1}{k}\prod^{n}_{k=2}\frac{k}{k+1} =\frac{2}{n(n+1)}$$ Hence $$b_{n+1}=- \frac{1}{n(n+1)}$$

Now I don't know which trick I should use here in other to come up with the closed form of $a_n$ Can someone provide some hint or an answer?


I will show you a more general way to find solutions, you can apply that method later to your problem ( and others of the same type)

Theorem(Solution of the recurrence) Given sequences $g(n) \neq 0$ and $b(n)$, we have that $f(n)$ the solution of the recurrence $$f(n+1)=g(n).f(n)+b(n)$$ is given by $$f(n)= \bigg(\sum^{n-1}_{p=1}\frac{b(p)}{\prod\limits^{p}_{k=1}g(k)}+f(1) \bigg)\prod^{n-1}_{k=1}g(k). $$

Moreover,: in the same way we can show $$ f(n)= h(c)\prod^{n-1}_{k=a}g(k) + \prod^{n-1}_{k=a}g(k)\bigg(\sum^{n-1}_{p=c}\frac{b(p)}{\prod\limits^{p}_{k=a}g(k)} \bigg)$$ Notation: $\Delta f(x)=f(x+1)-f(x)$

Proof\deduction

Let $h(n)$ be define by $$h(n)=\frac{f(n)}{\prod\limits^{n-1}_{k=a}g(k)},$$ so that, $$f(n)=h(n)\prod^{n-1}_{k=a}g(k) ~~~~and~~~~f(n+1)=h(n+1)\prod^{n}_{k=a}g(k) $$ substitute tha term on the recurrence, $$h(n+1)\prod^{n}_{k=1}g(k)=h(n)g(n)\prod^{n-1}_{k=1}g(k)+b(n)=h(n)\prod^{n}_{k=1}g(k)+b(n) $$ then $$ h(n+1)\prod^{n}_{k=1}g(k)-h(n)\prod^{n}_{k=1}g(k)= b(n)$$ $$\Delta h(n)\prod^{n}_{k=1}g(k)=b(n)$$ $$\Delta h(n)=\frac{b(n)}{\prod\limits^{n}_{k=1}g(k)} $$ apply the sum $\sum\limits^{n-1}_{p=1}$ on both sides, it's telescopic $$\sum^{n-1}_{p=1}\Delta h(p)=h(n)-h(1)=\sum^{n-1}_{p=1}\frac{b(p)}{\prod\limits^{p}_{k=1}g(k)}, $$ so $$h(n)=\sum^{n-1}_{p=1}\frac{b(p)}{\prod\limits^{p}_{k=1}g(k)}+h(1) $$ then $$f(n)= \prod^{n-1}_{k=1}g(k)\bigg(\sum^{n-1}_{p=1}\frac{b(p)}{\prod\limits^{p}_{k=1}g(k)}+h(1) \bigg). $$

Obs: $h(1)=f(1)$


Now, let $a_n=b_n+1$ for some sequence $b$.

Thus, $$b_{n+1}=(b_n+1)\frac{n-1}{n+1}+\frac{2}{n+1}$$ or $$b_{n+1}+1=\frac{n-1}{n+1}b_n+\frac{n-1}{n+1}+\frac{2}{n+1}$$ or $$b_{n+1}=\frac{n-1}{n+1}b_n$$ and use your work.