horner <- function ( x, coefs ) #*****************************************************************************80 # ## horner evaluates a polynomial using Horner's method. # # 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: # # Original R version by James Howard. # Modifications by John Burkardt. # # Reference: # # James Howard, # Computational Methods for Numerical Analysis with R, # CRC Press, 2017 # ISBN13: 978-1-4987-2363-3. # # Input: # # real X, the evaluation points. # # real COEFS, the polynomial coefficients. # # Output: # # real Y, the value of the polynomial at each point X. { y <- rep ( 0.0, length ( x ) ) for ( i in length ( coefs ) : 1 ) { y <- coefs[i] + x * y } return ( y ) }