horner_test <- function ( ) #*****************************************************************************80 # ## horner_test tests horner. # # 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: # # 15 January 2020 # # Author: # # John Burkardt # { cat ( "\n" ) cat ( "horner_test\n" ) cat ( " ", version$version.string, "\n" ) cat ( " horner evaluates a polynomial using Horner's method.\n" ) source ( "/home/burkardt/public_html/r_src/horner/horner.R" ) coefs <- c ( 24.0, -50.0, +35.0, -10.0, 1.0 ) cat ( "\n" ) cat ( " The polynomial coefficients:\n" ) print ( coefs ) x_lo <- 0.0 x_hi <- 5.0 x_inc <- 1.0 / 3.0 x <- seq ( x_lo, x_hi, x_inc ) cat ( "\n" ) cat ( " The evaluation points:\n" ) print ( x ) cat ( "\n" ) cat ( " I X P(X)\n" ) cat ( "\n" ) p = horner ( x, coefs ); for ( i in 1:length ( x ) ) { cat ( i, " ", x[i], " ", p[i], "\n" ) } # return ( ) }