Finding the maximum

Can anyone tell me the syntax to find the maximum of a function over the interval a≤x≤b starting at a with a step size of Δx ?
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.
Last edited on
Topic archived. No new replies allowed.