I am trying to make a program that finds the maximum of a function f(x) over an interval a<=x <=b by starting at x=a with a step size of Δx.I want to evaluate f1=f(x) and f2= f(x+Δx. If f1<f2, I should replace x with x+Δx and continue; otherwise, I should reduce the step size by half and repeat the comparison. The program should terminate successfully when Δ<10^-6.
I'm not sure exactly how to have the program look for the maximum. Also, I'm not sure if the loops I have so far are right.
Here's the code I've written so far.