local_min_example <- function ( a, b, f, title ) #*****************************************************************************80 # ## local_min_example() tests local_min() on one test function. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 12 June 2021 # # Author: # # John Burkardt # # Input: # # real A, B, the endpoints of the interval. # # real value = F ( x ), the name of a user-supplied # function whose local minimum is being sought. # # string TITLE, a title for the problem. # { source ( "/home/burkardt/public_html/r_src/local_min/local_min.R" ) epsi = .Machine$double.eps t = sqrt ( epsi ) output = local_min ( a, b, epsi, t, f ) x = output[1] fx = output[2] calls = output[3] fa = f ( a ) fb = f ( b ) cat ( "\n" ) cat ( title ) cat ( "\n" ) cat ( "\n" ) cat ( " A X B\n" ) cat ( " F(A) F(X) F(B)\n" ) cat ( "\n" ) cat ( " ", a, " ", x, " ", b, "\n" ) cat ( " ", fa, " ", fx, " ", fb, "\n" ) cat ( " Number of calls to F = ", calls, "\n" ) return }