Create std:vector<double> values (or array of size (b-a)/delta_x + 1). Store all the values of that function into values. Use std::max_element (values.begin(), values.end()) from #include<algorithm>, or std::sort. If you are not allowed to use that library, check each element of values, and store into double largest whenever x > largest. Let largest = values[0] initially.