# Rosenbrock function f <- function(x) { return( (x[1]-1)^2 + 100*(x[1]^2-x[2])^2 ) } x0 <- c(0, 0) # xの初期値 res1 <- optim(x0, f) # Nelder and Mead シンプレックス法 res2 <- optim(x0, f, method="BFGS") # 準ニュートン法 (BFGS法)