In the documentation for 'optim' it gives the following function:

fr <- function(x) {   ## Rosenbrock Banana function
    x1 <- x[1]
    x2 <- x[2]
    100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
optim(c(-1.2,1), fr)

When I run this code I get:

$par
[1] 1.000260 1.000506

I am sure I am missing something but why isn't 1,1 a better answer? If I plug 
1,1 in the function it seems that the function is zero. Whereas the answer 
given gives a function result of 8.82e-8. This was after 195 calls to the 
function (as reported by optim). The documentation indicates that the 'reltol' 
is about 1e-8. Is this the limit that I am bumping up against?



Kevin

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to