# Convex Function to Given (Three) Data Points

Assume that a function $h(x)$ is decreasing and convex given interval $[l,u]$. I'd like to get a function which connects three points, say $(a,h(a)), (b,h(b)), (c,h(c))$, where $l\leq a<b<c\leq u$. I wonder whether there is explicit formula or hand-solving way to obtain a such function form. ($h(x)$ is also differentiable in the interval.)

Any comments are welcome.

## 1 Answer

Such an $h$ exists if and only if $h(b)\leq h(a)+(b-a)\frac{h(c)-h(a)}{c-a}$. This is because the latter is the value at $b$ of the line between $(a,h(a))$ and $(c,h(c))$, and the graph of a convex function must lie below all such lines.

Given the condition on $h(b)$, there are infinitely many possible choices of differentiable convex function connecting your three points. Perhaps the prettiest choice is the unique quadratic function that does so. Since we've assumed no concave function, except maybe a line, connects these three points, and every quadratic function is convex or concave (or both, if it's really linear,) we'll certainly get a convex function.

The formula for the quadratic $h$ of interest is given by Lagrange interpolation, as follows: $$h(x)=h(a)\frac{(x-b)(x-c)}{(a-b)(a-c)}+h(b)\frac{(x-a)(x-c)}{(b-a)(b-c)}+h(c)\frac{(x-a)(x-b)}{(c-a)(c-b)}$$

One observation: really we could have written down $h$ without our assumption about $h(b)$. The assumption just makes $h$ convex; if $h(b)= h(a)+(b-a)\frac{h(c)-h(a)}{c-a}$ then $h$ will be linear, and if $h(b)> h(a)+(b-a)\frac{h(c)-h(a)}{c-a}$ it will be strictly concave.

• Given three points, the quadratic function (which passes those points) will be uniquely determined. So I agree with you that the convexity will be preserved if b is chosen appropriately. However, your suggestion does not consider $h$ should be monotone given interval. – chp61 Jan 9 '14 at 1:09