I want to calculate a finite difference (something like this SO Post). My data is as follows: I have x-values that are powers of two (4, 8, 16, 32 and 64). Corresponding to them are y-values, such that
$$Y=f(X)$$
where $f$ is a monotonic function. My interest is in calculating finite difference such as
$$\text{Diff}(x) = (y_2-y_1) /(x_2-x_1)$$ at different values of X, where X is in the domain (i.e. $4\le x \le 64$). Now my problem is that when I take piecewise linear approximation, Diff(x) changes a lot between 4-to-8 and 8-to-16. This is undesirable. If I try to fit quadratic equation, by taking three points at a time, and then calculate finite difference, it becomes negative at some points, which is not physically acceptable, since $f$ is monotonic function. In other words, I fitted $ax^2+bx+c$ and thus $\text{Diff}(X)=2ax+b$. So, the problem is that $2ax+b$ is not positive at all points in the domain.
Can someone point-out a method to solve this problem. I need to use C/C++ for solve this, I cannot use matlab. I just have five X values, so solution of any complexity is acceptable. Thanks for the help.