#*****************************************************************************80 # ## goldsectmax_test tests goldsectmax. # # Licensing: # # Copyright 2016 James P. Howard, II # # The computer code and data files on this web page are distributed under # https://opensource.org/licenses/BSD-2-Clause, the BSD-2-Clause license. # # Modified: # # 14 March 2020 # # Author: # # John Burkardt # cat ( date ( ), "\n" ) cat ( "\n" ) cat ( "goldsectmax_test\n" ) cat ( " ", version$version.string, "\n" ) cat ( " goldsectmax seeks the maximum of a function using golden section.\n" ) cat ( "\n" ) source ( "/home/burkardt/public_html/r_src/goldsectmax/goldsectmax.R" ) f <- function ( x ) { - x^2 + 4.0 * x + 1.0 } a = 1.0 b = 3.0 value <- goldsectmax ( f, a, b, tol = 1.0e-3 ) cat ( " goldsectmax(-x^2+4*x+1, 1, 3, 1.0-3) = ", value, "\n" ) # # Terminate. # cat ( "\n" ) cat ( "goldsectmax_test\n" ) cat ( " Normal end of execution.\n" ) cat ( date ( ), "\n" ) quit ( )