Guarantees on computing $a+x(b-a)$ in floating point

I want to implement the function $ f(x,a,b) = a + x(b-a)$ where all the inputs are floating point (doubles, say), such that (a) $ f(0,a,b)=a$ exactly; (b) $ f(1,a,b)=b$ exactly; (c) $ f(x,a,b) \le f(y,a,b)$ whenever $ x \le y$ ; and preferably (d) it is accurate (correct up to rounding).

Implementing $ f(x,a,b)=a+x(b-a)$ directly does not work because for example $ f(1.0,-1.0,\operatorname{prev}(1.0)) = 1.0$ (where $ \operatorname{prev}(a)$ is the floating point number before $ a$ ). And $ f(x,a,b)=b-(1-x)(b-a)$ has the same issue.

Now $ $ f(x,a,b) = (1-x)(a+x(b-a))+x(b-(1-x)(b-a))$ $ has the first two properties.

  • Does it have property (c)?
  • How accurate is it?
  • Is there a more performant way to do this?