# NOT RUN {
# Let x = (x[1], x[2], x[3])', and
# f(x) = (x[1]^3 - 2 * x[2] + 1, sin(x[1] * x[3]), log(x[2] + x[3]))'.
# Approximate d f^{T}(x) / d x at x = (1, 2, 3)'.
# The true value of the derivative is
# [ 3 3cos(3) 0
# -2 0 0.2
# 0 cos(3) 0.2] .
f.fct <- function(x) {
c(x[1]^3 - 2 * x[2] + 1,
sin(x[1] * x[3]),
log(x[2] + x[3]))
}
num.deriv.fct(f.fct, c(1, 2, 3))
# }
Run the code above in your browser using DataLab