Question: For a computer vision program, I have values **between $0$ and $255$** that need to follow a **cubic function ($y=x^3$) behavior** so that :

* $f(255) = 255$
* $f(\frac{255}{2}) = 128$
* $f(0) = 0$

But I don't know how to find its equation. Thank you for your help.

Answer: 
A natural parameterIn addition to your own answer: a natural 4th condition is to fix the slope in the middle (that's the only thing you are allowing to change). This makes sense, because it defines the contrast of the nonlinear mapping. Using it this way, you can get through analytically.

Let's stretch everything to the unit square (divide $x$ and $y$ by $255$).

Start with a *centered* cubic curve (only odd terms allowed to keep the symmetry), it has one important parameter $a$ that sets the slope through the center:
$$y(x)=x^3+ax$$

Make it go through $(1,1)$:

$$y(x)=\frac{x^3+ax}{1+a}$$

Now it goes from (-1,-1) to (1,1) and is symmetric around the center. Squeeze it into the box from (0,0) to (1,1) by scaling by factor of 1/2 and shifting by 1/2 in both axes:

$$y(x)=\frac12+\frac12\left(\frac{(2x-1)^3+a(2x-1)}{1+a}\right)$$

$2x-1$ is there so that it maps 0 to -1 and 1 to 1.

This is already a final solution (replace $x$ by $x/255$ and multiply result by $255$ to go back to byte values). This shows that most ugly terms come from expanding the powers, but actually, the function is much more simple and this is also how you should compute it if you are using floating point numerics (if using integers/bytes, then you must expand).

For different values of $a$ it has different slopes, but all go through desired points. A special case $a=0$ which has horizontal tangent is also interesting. Negative values of $a$ don't produce unique mappings (not one-to-one), so probably should be discarded, depending on what you want.

If you make $a$ very big, you converge towards linear mapping $y=x$.

An image showing a few samples:

[![enter image description here](https://i.stack.imgur.com/WzvhN.png)](https://i.stack.imgur.com/WzvhN.png)
Thanks to @lulu, I've found a good solution to my problem.
Using [Wolfram Alpha](https://www.wolframalpha.com)

First, here is what I was expecting as the result function :
![Original schema](https://i.stack.imgur.com/4h95q.png)

But to determine a cubic function equation, you need a 4th parameter.
I did the hypothesis that $f(64) ~= 115$.

So I've searched for `InterpolatingPolynomial[(0,0),(255,255),(255/2,128),(64,115)]` in [Wolfram Alpha](https://www.wolframalpha.com) which outputed the following schema :
![Schema for hypothesis f(64) = 115](https://i.stack.imgur.com/NcwbE.png)

It was a pretty good result. But I wanted that $f(127)>=f(128)>=f(129)$.

So, advised by @lulu, I've tried `InterpolatingPolynomial[(0,0),(255,255),(255/2,128),(64,110)]`.

And it outputed a satisfying result !

![Schema for hypothesis f(64) = 110](https://i.stack.imgur.com/G9s2b.png)

Here is by consequence the final savage equation :
$\frac{577744073\*x}{197937120} - \frac{1136315963\*x^2}{50473965600}+\frac{1483351\*x^3}{25236982800}$.

Or for those who want it to computer programs :
`(577744073*x)/197937120 - (1136315963*(x^2))/50473965600 + (1483351 *(x^3))/25236982800`.