[Math] formula for an upwards-sloping convex curve with known endpoints

graphing-functionsinterpolation

For a project I am working on, I need a formula that can describe a curve between two known endpoints, where the curve will always be upwards sloping and always convex (or flat). There should be many solutions to this but I have not been able to develop any that work.

So in the illustration below, changing the input parameter would change the precise path followed by the function without changing the endpoints, and without violating the conditions that it always be upwards sloping and convex.

Any assistance would be appreciated.

enter image description here

Best Answer

Suppose the two end-points are $(x_0, y_0)$ and $(x_1, y_1)$.

Use the function

$$ f(x) = \frac{(x_1-x)^2 y_0 + 2(x_1 - x)(x- x_0)h + (x - x_0)^2 y_1 }{(x_1 - x_0)^2} $$

The $h$ is a free parameter. You can adjust its value between $\tfrac{1}{2}(y_0 + y_1)$ and $y_1$.

If $(x_0, y_0) = (0,0)$ and $(x_1, y_1) = (1,1)$, as in your picture, then this $f$ simplifies greatly. It just becomes

$$ f(x) = (1 - 2h)x^2 + 2hx$$

Again, in this special case, you can adjust $h$ to have any value between 0.5 and 1. When $h=0.5$, you get a straight line. When $h=1$, you get a curve whose tangent is horizontal at the right-hand end.

Related Question