---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
# The graph of a function x -> f(x) and finding where it has a "bump"
f = function(x) x^3-x
graphF(f,-3,3, "blue")
                      
# I want to look for x such that around it  x^3 - x  has a minimum value
graphF(f,-2,2, "blue")
                      
# Between 0 and 1 the graph has a hump.
# I define a procedure that trisects the interval and selects the two subintervals
# in which the graph has a hump.
       
# In case (1) I take the two subintervals to the right, in case (2) those to the left
#
Min = function(f,a,b) {h=(b-a)/3;y1=f(a);y2=f(a+h);y3=f(a+2*h);if(y1>y2 & y2>y3) a<<-a+h else b<<- b-h}
#
a=0 ;b=1
Min(f,a,b); c(a,b)
#  0.3333333  1.0000000
Min(f,a,b); c(a,b)
#  0.3333333  0.7777778
Min(f,a,b); c(a,b)
#  0.4814815  0.7777778
Min(f,a,b); c(a,b)
#  0.4814815  0.6790123
#...
Min(f,a,b); c(a,b)
#  0.5773502 0.5773503
Min(f,a,b); c(a,b)
#  0.5773503  0.5773503
#
# The procedure "mimmax" automates this process.