# Is there a math function for $x + x^2 + x^3 + x^4 + x^5 + \cdots$?

I'm a UI programmer and I've trying to calculate an effect related to mouse scroll. The behavior I'm noticing is equivalent to

$$x + x^2 + x^3 + x^4 + x^5 + \cdots$$

For the purposes of my app, I only need to go to like $$x^3$$ before the result is close enough, but I'm wondering if there is a mathematical function or operator, ideally one build into common programming languages, designed for this kind of thing that has greater precision.

Thanks!

• Welcome to MSE. Please edit and use MathJax to properly format math expressions. – Lee David Chung Lin May 11 '19 at 2:01
• What is the typical range of values expected for $x$? – Spencer May 11 '19 at 2:11
• @Spencer x should be: $-1 < x < 1$ – weotch May 11 '19 at 2:18
• In that case the given answers are sufficient. You should add that detail to your question. – Spencer May 11 '19 at 2:19

If $$x$$ is a number between $$-1$$ and $$1$$, then you can calculate the infinite sum $$x + x^{2} + x^{3} + \dots$$.
If we set $$m =x + x^{2} + x^{3} + \dots \,\,\,\,\,\,\,\,\,\,\,\,\,\,(1)$$ then clearly, multiplying both sides of (1) by $$x$$, we get $$m\cdot x = x^{2} + x^{3} + \dots.$$ This means we can rewrite the original expression (1) as $$m = x + m\cdot x$$, and isolating the $$m$$ gives $$m - m\cdot x = x$$, i.e., $$m(1 - x) = x$$, so that we can solve for $$m$$: $$m = \frac{x}{1-x}$$.
All of this to say if $$x$$ satisfies $$-1 < x < 1$$, then the infinite sum $$x + x^{2} + x^{3} + \dots$$ can be calculated simply as $$\frac{x}{1 - x}$$.
It is a geometric series and it can be expressed as it follows (for $$|x| < 1)$$ \begin{align*} & S(x) = x + x^{2} + x^{3} + \ldots \Rightarrow xS(x) = x^{2} + x^{3} + x^{4} + \ldots \Rightarrow\\\\ & S(x) - xS(x) = S(x)(1 - x) = x \Rightarrow S(x) = \frac{x}{1-x} \end{align*}