What if I need to calculate the Taylor Series approximation for a function of two variables, is it possible in R? My function of interest is e raised to the power of the sum of variables x1 and x2: e^(x1 + x2)
Since there's taylor
function in pracma
library, I try something like this:
func <- function(x) exp(1)^(x[1]+x[2])
vars <- c(0, 0) # evaluated at point (0,0)
taylor(func, vars, 2)
But R says Error in fderiv(f, x0, i) : Function 'f' must first be vectorized: Vectorize(f).
So, what am I doing wrong and is possible at all for a function of two variables?