I am trying to create a nice ease-in-out function that given values from 0 - 1 produces an output of 0 - 1 which accelerates slowly up to full speed then slows down again as it nears 1.

I currently have a function using sine, in the form...

$$y = (\sin(πx/2))^2$$

This works ok, and gives me results in the range I require however it is too quick to reach the terminal velocity, I am looking for something which has a more gradual start / end and a steeper center (if that makes sense).

Any help would be appreciated!

  • $\begingroup$ You mean $y=(\sin(\pi x/2))^2$? $\endgroup$ – joriki Mar 18 '12 at 15:43
  • $\begingroup$ Yes, this is from code hence the difference :) Have updated the question, thanks. $\endgroup$ – Simon Lee Mar 18 '12 at 16:01
  • $\begingroup$ You get the right formatting for $\sin$ using \sin. If you just type sin, $\TeX$ interprets that as juxtaposed variable names and italicizes them. Also, you get equations in display style by using double dollar signs instead of single dollar signs. $\endgroup$ – joriki Mar 18 '12 at 16:16

Something to try would be the parametrized function $$ f_\alpha(x)=\frac{x^\alpha}{x^\alpha+(1-x)^\alpha} $$ $f_1(x)=x$ and $f_2(x)$ looks like this


As $\alpha$ gets bigger, the slope in the middle becomes greater and the ends at $x=0$ and $x=1$ become flatter. As $\alpha\to\infty$, the curve tends toward a step function.

  • $\begingroup$ This is pure simplicity, thanks. $\endgroup$ – Simon Lee Mar 18 '12 at 20:56
  • $\begingroup$ Lovely! Thanks @robjohn! $\endgroup$ – Scott Thiessen Feb 27 '14 at 22:06
  • $\begingroup$ So much more intuitive than the "famous" Penner solutions! And can be coded much more succinctly, too! Thank you! $\endgroup$ – Scott Biggs Apr 8 '15 at 6:45
  • $\begingroup$ Is there a way to make similar function for "ease-in" effect, withiut "out"? $\endgroup$ – raacer Aug 9 '15 at 19:29
  • $\begingroup$ @raacer: how would you like the function to look? I am not sure what you mean by "ease-in without ease-out". $\endgroup$ – robjohn Aug 10 '15 at 14:08

You could also use a polynomial that's $0$ at $0$, $1$ and $1$ and has zero derivative at both ends; the unique polynomial of degree $3$ with those properties is $y=x^2(3-2x)$.

In both of those functions, you can replace $x$ by


and choose $\alpha$ to achieve the desired steepness, with $\alpha\to0$ corresponding to $u=x$ and $\alpha\to\infty$ corresponding to a step function.

  • $\begingroup$ Perfect, many thanks for your help (with question formatting and answer!) $\endgroup$ – Simon Lee Mar 18 '12 at 16:25
  • $\begingroup$ @Simon: You're welcome. $\endgroup$ – joriki Mar 18 '12 at 16:33
  • 1
    $\begingroup$ @Simon: if you think the answer is useful (and since you've accepted it, it seems you do), you might also want to upvote it (you can only accept one answer, but you can upvote as many as you like). $\endgroup$ – robjohn Mar 18 '12 at 16:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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