Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm building an algorithm to determine whether a value is inside a series. To speed it up, I need the inverse function of the following series:

$$1 + 2 + 3+\cdots +n$$

What is the inverse function of $f(n) = \frac{n(n + 1)}{2}$?

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

I don't understand much of your question, but if $$f(n)={n(n+1)\over2}$$ then $$8f(n)+1=(2n+1)^2$$ so $$n={\sqrt{8f(n)+1}-1\over2}$$

share|improve this answer
    
I'm trying to get the inverse function of $[n(n+1)]/2$ I'm testing your solution right now, thanks for posting! –  Tyymo Jun 29 '12 at 5:46
    
Also, can you explain a bit more about the second step? Thank you –  Tyymo Jun 29 '12 at 5:48
    
@Guy: That's exactly what Gerry gave. Try plugging in a specific $n$: letting $n=3$, then we have that $f(3)=\frac{3^2+3}{2}=6$, and $$\frac{\sqrt{8f(n)+1}-1}{2}=\frac{\sqrt{8\cdot 6+1}-1}{2}=\frac{\sqrt{49}-1}{2}=\frac{6}{2}=3$$ –  Zev Chonoles Jun 29 '12 at 5:48
    
First you multiply both sides by 8 and add 1, noting the resulting right side factors. Then you take the square root, subtract 1, and divide by 2. –  Gerry Myerson Jun 29 '12 at 5:57
    
Thank you for clarifying! I really appreciate it. –  Tyymo Jun 29 '12 at 6:33
add comment

Inverse of given function is $\frac{\sqrt{8f(n)+1}-1}2$(as solved by @Gerry Myerson),but this function is helpful only if the series you are considering is first $n$ natural numbers(in that case, every integer $\geq 1$ and $\leq$ number provided by this inverse function is in the series).

share|improve this answer
add comment

$$ f(n)={n(n+1)\over2}$$ $$\implies 2 f(n) = n^2+n$$ $$\implies 2f(n) +\frac 14 = (n)^2 + 2\times n\times \frac 1 2 +\left(\frac 12\right)^2 $$

$$\implies 2f(n)+\frac 1 4 = \left(n+\frac 12 \right)^2 $$ $$\implies n = \sqrt{2 f(n)+\frac{1}{4}} -\frac{1}{2}$$

$$ \implies n = \frac{\sqrt{8 f(n)+1}}{2} -\frac{1}{2}$$

which gives the expression @Gerry Myerson posted.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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