I guess you can evaluate your functions at different values and get the coefficients by solving those linear equations.
> # In your example
> a <- 2
> b <- 3
> aFun <- function(y) {1 + a*y + b*y^2 + 3*y^3}
> # Highest order of your polynomial
> n <- 3
> # Here, we are going to evaluate the function
> # at 1,2, ..., n + 1
> # Independent variable at different orders
> ivs <- outer(c(1:(n + 1)), c(0:n), "^")
> # Values of functions at correcponding y values
> # e.g., aFun(1), aFun(2), aFun(3), aFun(4)
> funVal <- sapply(1:(n + 1), aFun)
> # Find the coefficients of the function by
> # solving the equations
> coeff <- solve(ivs, funVal)
> coeff
[1] 1 2 3 3
复制代码
The only thing you need to know before hand is the highest oder of your polynomial. I can not think of any good way to find it out in case you do not know it.