R/polyHorner.R

Defines functions polyHorner

Documented in polyHorner

#' Horner's method to evaluate a polynomial, copied from the polynom package. the most efficient way
#' @param coefs the polynomial coefficients
#' @param x the input values for the polynomial function
#'
#' @return the evaluated polynomial
polyHorner = function(coefs, x){
    out = 0
    for(coefj in coefs) out = x*out + coefj
    out
}

Try the combi package in your browser

Any scripts or data that you put into this service are public.

combi documentation built on Nov. 8, 2020, 5:34 p.m.