Computing the improper integral of several functions
You are assuming the functions in &lt;cmath&gt; (e.g. fabs(), sin()) etc. are in the global namespace already. However, it is unspecified in the standard whether or not these functions exist in the global namespace. The easiest way to ensure they are in the global namespace is to add using namespace std; to the appropriate source file, but that's bad practice. A better practice would be to add using declarations (preferably in the most local scope possible), or simply add std:: to the beginning of each function call.



There is little point in passing a primitive like double by const reference rather than by value. The performance is about the same and it saves you typing to pass by value.



Areas of your code are difficult to read due to lack of spacing. For example:

while(eps&lt;fabs(previousSum-currentSum));


The same line is easier to read like this:

while (eps &lt; fabs(previousSum - currentSum));


Similarly, this:

for(int i(1); i &lt; n; i+=2)
    {s4 += f(a+i*step);}


would be easier to read with the { and } on their own lines like this:

for (int i(1); i &lt; n; i += 2)
{
  s4 += f(a + i*step);
}




If your compiler supports C++11 or later you may want to initialize with curly braces ({, }) to avoid the most vexing parse.