I have the following sequence:
$$1, 2 \cos(x),~ 1+2 \cos(2x),~ 2 \cos(x)+2 \cos(3x)….$$
I need to find the $n^{\text{th}}$ term, considering the $1^{st}$ term as $1$, $2^{nd}$ as $2 \cos(x)$ and so on.
We can represent it by a recurrence function as:
$$f(n) = f(n-2) + 2\cos((n-1) x), f(1) = 1, f(2) = 2\cos(x)$$
So what is the non-recursive version of the function, or how to approach to find one?
For odd $n=2k+1$, we have $$ f_n = f_1+\sum_{j=1}^{k}\left( f_{2j+1} - f_{2j-1}\right)=1+2\sum_{j=1}^k \cos (2jx). $$ For even $n=2k$, we have $$ f_n = f_2+\sum_{j=2}^{k}\left( f_{2j} - f_{2j-2}\right)=2\sum_{j=1}^k \cos \left((2j-1)x\right). $$