# NOT RUN {
func0 <- function(x){ sum(sin(x)) }
x <- (0:10)*2*pi/10
nlmixrHess(x, func0)
fr <- function(x) { ## Rosenbrock Banana function
x1 <- x[1]
x2 <- x[2]
100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
grr <- function(x) { ## Gradient of 'fr'
x1 <- x[1]
x2 <- x[2]
c(-400 * x1 * (x2 - x1 * x1) - 2 * (1 - x1),
200 * (x2 - x1 * x1))
}
h1 <- optimHess(c(1.2,1.2), fr, grr)
h2 <- optimHess(c(1.2,1.2), fr)
## in this case h3 is closer to h1 where the gradient is known
h3 <- nlmixrHess(c(1.2,1.2), fr)
# }
Run the code above in your browser using DataLab