Don't use array (std::vector<double>) to precompute points of interval segmentation. It is ill designed which could be clearly seen if one uses too small step, like 1e-9. This step will cause to allocate array for 1e9 elements that is used only in one place, for for loop. It is much easier and resource lighter to use more conventional while loop.