Looking for a closed-form expression of a function

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

Looking for a closed-form expression of a function

Postby JTHM » Thu May 31, 2012 4:42 am UTC

Suppose I have a natural number x greater than 0, and I want to find some n such that x is greater than or equal to the sum of the natural numbers from 1 to n, and less than the sum of the natural numbers from 1 to n+1. Does anyone know of a closed-form expression for this function? If not, does anyone know of an efficient algorithm for calculating it?
JTHM
 
Posts: 16
Joined: Sun Apr 22, 2012 4:29 am UTC

Re: Looking for a closed-form expression of a function

Postby ConMan » Thu May 31, 2012 4:56 am UTC

Well, the sum of natural numbers from 1 to n is the nth triangular number, given by T(n) = n(n+1)/2, so you're basically trying to find the inverse function T^-1(x), then taking the floor of this value. A quick bit of algebra gives:

x = T(y) = y(y+1)/2
y² + y - 2x = 0
y = (-1 + sqrt(1 + 8x))/2 <- taking the positive solution only since you want a natural number
n = floor(y) = floor((sqrt(8x + 1) - 1)/2)
pollywog wrote:
Wikihow wrote:* Smile a lot! Give a gay girl a knowing "Hey, I'm a lesbian too!" smile.
I want to learn this smile, perfect it, and then go around smiling at lesbians and freaking them out.
User avatar
ConMan
 
Posts: 1209
Joined: Tue Jan 01, 2008 11:56 am UTC
Location: Where beer does flow, and men chunder.

Re: Looking for a closed-form expression of a function

Postby JTHM » Thu May 31, 2012 5:06 am UTC

Thanks!
JTHM
 
Posts: 16
Joined: Sun Apr 22, 2012 4:29 am UTC


Return to Mathematics

Who is online

Users browsing this forum: No registered users and 7 guests