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.


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

I am going to expand on the answer already posted. Feel free to skip the details in my post and read the last line below.

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}$.

  • $\begingroup$ Holy moly, I hadn't noticed that ... amazing. Thank you! $\endgroup$ – weotch May 11 at 2:21
  • $\begingroup$ @weotch You're welcome! This infinite sum has a special name: geometric series. $\endgroup$ – layman May 11 at 2:22

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*}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.