Easing function, constant velocity then decelerate to zero I'm trying to write an interpolator for a translate animation, and I'm stuck. The animation passes a single value to the function. This value maps a value representing the elapsed fraction of an animation to a value that represents the interpolated fraction. The value starts at 0 and goes to 1 when the animation completes. So for instance, if I wanted a linear translation (constant velocity) my function would look like:
function(input) {
  return input
}

What I need is for the velocity to remain constant for half the animation, then decelerate rapidly to zero. What this essentially means is that the input values I return must be the same as the output values for half the animation (until 0.5), then the values must increase from 0.5 to 1.0 at a slower rate of change between calls than the input value change between calls.

EDIT (straight from the Android docs):

The following table represents the approximate values that are calculated by example interpolators for an animation that lasts 1000ms:

As the table shows, the LinearInterpolator changes the values at the same speed, .2 for every 200ms that passes. The AccelerateDecelerateInterpolator changes the values faster than LinearInterpolator between 200ms and 600ms and slower between 600ms and 1000ms.

EDIT 2:

I thought I should provide an example of something that works, just not the way I want it to. The function for a decelerate interpolation provided with the Android framework is exactly:
function(input) {
  return (1 - (1 - input) * (1 - input))
}

 A: Let $s(t)$ denote the distance moved at time $t$. Choose some value $h$ with $0 \le h \le 1$. Then the required function is:
$$s(t) = \frac{2t}{1+h} \quad \text{for } 0 \le t \le h $$
$$s(t) = \frac{t^2 - 2t + h^2}{h^2 - 1} \quad \text{for } h \le t \le 1 $$
The first part of the curve (where $0 \le t \le h$) is a straight line, obviously.
The second part (where $h \le t \le 1$) is a piece of parabola. At $t=h$, the line and the parabola join smoothly. 
The speed of the particle varies as follows:
From $t=0$ to $t=h$, the speed is constant, $2/(1+h)$.
From $t=h$ to $t=1$, the speed gradually decreases.
At $t=1$, the speed is zero.
You can adjust $h$ to get the behaviour you want. Any value with $0 \le h \le 1$ will work.
If you choose $h=0$, you get the Android function.
If you choose $h=1$, you get purely linear motion.
Here's what the composite curve looks like when we choose $h=0.5$:

A: This answers a problem motivated by your description, but it may not be the problem you want to solve. We assume constant velocity $k$ for $0\le t\le 0.5$. Then we have constant deceleration, so that at time $t=1$ velocity reaches $0$.
Under these conditions, you may want the net displacement at time $t$.
Our velocity at $t=0.5$ is $k$. It has to reach $0$ at time $1$, so the velocity at time $t$, for $0.5\le t\le 1$, is $k-\frac{k}{1-0.5}(t-0.5)=2k-2kt$.
Our net displacement $s(t)$ at time $t$ is $kt$ for $0\le t\le 0.5$.
For $0.5\lt t\le 1$, the net displacement is $(0.5)k +\int_{0.5}^t (2k-2kt)\,dt$. This simplifies to  $2kt-kt^2-0.25k$. 
Thus a formula for the net displacement $s(t)$ at time $t$ is $s(t)=kt$ for $0\le t\le 0.5$, and $s(t)=2kt -kt^2-0.25k$ for $0.5\lt t\le 1$.  
