Function for polynomials of arbitrary order (symbolic method preferred)
问题 I've found polynomial coefficients from my data: R <- c(0.256,0.512,0.768,1.024,1.28,1.437,1.594,1.72,1.846,1.972,2.098,2.4029) Ic <- c(1.78,1.71,1.57,1.44,1.25,1.02,0.87,0.68,0.54,0.38,0.26,0.17) NN <- 3 ft <- lm(Ic ~ poly(R, NN, raw = TRUE)) pc <- coef(ft) So I can create a polynomial function: f1 <- function(x) pc[1] + pc[2] * x + pc[3] * x ^ 2 + pc[4] * x ^ 3 And for example, take a derivative: g1 <- Deriv(f1) How to create a universal function so that it doesn't have to be rewritten for