On Tue, Mar 17, 2009 at 7:10 PM, Ravi Varadhan <rvarad...@jhmi.edu> wrote: > Here is how you can implement the Lagrangian multiplier approach and solve > the first-order KKT conditions to obtain the solution for Paul Smith's > example: > > require(BB) > > f2 <- function(x) { > f <- rep(NA, length(x)) > f[1] <- 1 + 2 * x[1] * x[3] # x[3] is the Lagrangian multiplier > f[2] <- 1 + 2 * x[2] * x[3] > f[3] <- x[1]^2 + x[2]^2 - 1 # the equality constraint > f > } > > dfsane(par=rep(0, 3), fn=f2)
I would suggest to run dfsane(par=runif(3), fn=f2) several times to get the chance of obtaining all critical points. Paul ______________________________________________ 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.