https://github.com/CompPhysics/ComputationalPhysics/blob/42e9ccf2cb74744b0568aac7d92ccf8ccdb5b23d/doc/Programs/LecturePrograms/programs/NumericalIntegration/cpp/program1.cpp#L32