$\frac{1}{x+1} + \frac{2}{x^2+1} + \frac{4}{x^4+1} + \cdots $ up to $n$ terms in terms of $x$ and $n$. There's a series which I can't seem to find a way to sum. Any help would be highly appreciated. It goes as follows      $$\frac{1}{x+1} + \frac{2}{x^2+1} + \frac{4}{x^4+1} + \cdots $$ up to $n+1$ terms.   The sum is to be expressed in terms of $x$ and $n$. I tried setting a formula for the $n$-th term and setting it into a difference but ran into a dead end.
 A: By induction, it is pretty clear that
$$ x^{2^{n+1}}-1 = (x-1)\prod_{k=0}^{n} \left(x^{2^k}+1\right) \tag{A}$$
and by applying $x\cdot\frac{d}{dx}\log(\cdot)$ to both sides we have:
$$\frac{2^{n+1}x^{2^{n+1}} }{x^{2^{n+1}}-1}=\frac{x}{x-1}+\sum_{k=0}^{n}\frac{2^k x^{2^k}}{x^{2^k}+1} \tag{B}$$
and by replacing $x$ with $\frac{1}{z}$:
$$\frac{2^{n+1}}{1-z^{2^{n+1}}}=\frac{1}{1-z}+\sum_{k=0}^{n}\frac{2^k}{z^{2^k}+1}. \tag{C}$$
A: A supplement to the nice answer from @labbhattacharjee. We see an example of telescoping based upon
\begin{align*}
\color{blue}{\frac{2^k}{1-x^{2^k}}+\frac{2^k}{1+x^{2^k}}}
=\frac{2^k\left(1+x^{2^k}\right)+2^k\left(1-x^{2^k}\right)}{\left(1-x^{2^k}\right)\left(1+x^{2^k}\right)}
&\color{blue}{=\frac{2^{k+1}}{1-x^{2^{k+1}}}}\tag{1}
\end{align*}

We obtain according to (1)
  \begin{align*}
\color{blue}{\sum_{k=0}^n\frac{2^k}{1+x^{2^k}}}&=\sum_{k=0}^n\left(\frac{2^{k+1}}{1-x^{2^{k+1}}}-\frac{2^k}{1-x^{2^k}}\right)\\
&=\sum_{k=0}^n\frac{2^{k+1}}{1-x^{2^{k+1}}}-\sum_{k=0}^n\frac{2^k}{1-x^{2^k}}\\
&=\sum_{k=1}^{n+1}\frac{2^{k}}{1-x^{2^{k}}}-\sum_{k=0}^n\frac{2^k}{1-x^{2^k}}\tag{2}\\
&\color{blue}{=\frac{2^{n+1}}{1-x^{2^{n+1}}}-\frac{1}{1-x}}\tag{3}
\end{align*}

Comment:


*

*In (2) we shift the index of the left-hand sum to start with $k=1$.

*In (3) we do the telescoping.
A: Hint:
If $f(x)=\dfrac1{1+x}+\dfrac2{1+x^2}+\dfrac4{1+x^4}+\cdots+\text{ up to } n+1\text{ terms}$
$$\dfrac1{1-x}+f(x)=\dfrac1{1-x}+\dfrac1{1+x}+\left(\dfrac2{1+x^2}+\dfrac4{1+x^4}+\cdots+\text{ up to } n+1\text{ terms}\right)$$
$$=\dfrac2{1-x^2}+\dfrac2{1+x^2}+\left(\dfrac4{1+x^4}+\cdots+\text{ up to } n\text{ terms}\right)$$
$$=\dfrac4{1-x^4}+\dfrac4{1+x^4}+\left(\dfrac8{1+x^8}+\cdots+\text{ up to } n-1\text{ terms}\right)$$
