Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a formula that, given a linear $x$ input, would yield values of $y$ in a "stairs" shape so to speak, in such a way that as the value of $x$ grows higher, the difference between each step is bigger, and it also takes longer to reach the next the step, as this graph (hopefully) illustrates:

enter image description here

As you have probably guessed by now I'm not a mathematician, but I'm fairly sure this has an easy solution. I've been playing around with modulus and powers but I couldn't quite get the graph above so far.

Edit: Graph updated.

share|cite|improve this question
Do you need all the points (i.e. the where the vertical meets the horizontal) of each step to lie on a straight line? – Chuck Aug 12 '12 at 12:52
@Chuck correct. For instance, a subset sample of $y$ values could look like: [2, 2, 2, 2, 5, 5, 5, 5, 5, 8, 8, 8] etc – Mahn Aug 12 '12 at 12:55
Graph updated, silly me. – Mahn Aug 12 '12 at 13:00
For a linear stepcase, we would assume that without a "floor" function, it could be simplified to the form of $y=kx$. Then using $f(x)$ and $f^{-1}(x)$ simultaneously could achieve this effect. – Frenzy Li Aug 12 '12 at 13:11
up vote 5 down vote accepted

My first intuition is $y=2^{\lfloor\log_2\,x\rfloor}$. It's very pretty though:

plot of 2^{\lfloor\log_2\,x\rfloor}

share|cite|improve this answer
@J.M. Thanks for the beautified formula. – Frenzy Li Aug 12 '12 at 13:03
Thank you very much, this gets very near what I was after, and with a couple of variables added to the mix it works wonderfully. – Mahn Aug 12 '12 at 14:53

Writing $[x]$ for the integer part of $x$, how about $y=[\sqrt x]^2$?


The plot

share|cite|improve this answer
I think that in this case, the width of staircases is growing at a fairly slow pace (slower than exponential). But it fits the given picture better. – Frenzy Li Aug 12 '12 at 13:04
Thanks for adding the plot! – Gerry Myerson Aug 12 '12 at 13:33
np :) :) double smile for char[15+1] limit – Frenzy Li Aug 12 '12 at 13:39
Great answer, I can't accept two answers but this one also came close, you have my upvote. – Mahn Aug 12 '12 at 14:54

It might be too steep for what you want though.

$\large y = \left \lfloor \frac{-1 + \sqrt{8x+1}}{2} \right \rfloor$


A Plot of the function

share|cite|improve this answer
A bit too step indeed but great approach nonetheless, I will remember this formula in case I need it in the future, thanks! – Mahn Aug 12 '12 at 14:56

Your Answer


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.