# NOT RUN {
# }
# NOT RUN {
f <- function(x) 3*x[1]^3 - 4*x[2]^2
par <- c(3,8)
# grad = 9 * x^2 , 8 * y
c(81, -64)
numerical_deriv(par, f, type = 'forward')
numerical_deriv(par, f, type = 'central')
numerical_deriv(par, f, type = 'Richardson')
# hessian = h11 -> 18 * x, h22 -> 8, h12 -> 9 * x^2 + 8 * y
matrix(c(54, 0, 0, -8), 2, 2)
numerical_deriv(par, f, type = 'forward', gradient = FALSE)
numerical_deriv(par, f, type = 'central', gradient = FALSE)
numerical_deriv(par, f, type = 'Richardson', gradient = FALSE)
# }
Run the code above in your browser using DataLab