Skip to content

extracting more information from optim in R?

2 messages · Steve Su, Bart Joosen

#
I have no experience with writing C code, but if I have such problems in R
code, I add a line to my function which prints the values to the console:
eg:
fr <- function(x) {   ## Rosenbrock Banana function
    x1 <- x[1]
    x2 <- x[2]
	cat (paste(x1, x2, "\n"))
    100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
optim(c(-1.2,1), fr)

If the same goes for C, I don't know.

Bart