Numerical differentiation of data in C++