1 Find the 2 extrema of the Rosenbrock function

It appears as though Yun-Wei Shang and Yu-Huang Qiu state the local minima to exist in the 4th dimension at (-0.77565923, 0.61309337, 0.38206285, 0.14597202) in “A Note on the Extended Rosenbrock Function”. The authors used the gradient decent as the method to find this, however I am unable to replicate their results using this method.

My estimate of the extrema is extrememly close to the theoretical counterparts reported as (1, 1, 1, 1).

\[f\left(\text{x}\right)=f(x_{1\:},x_2,x_3,x_4)=\sum_{i=1}^2\left[100(x_{2i-1}^2-x_{2i})^2+(x_{2i-1}-1)^2\right]\]

# Modified from Data Science and Predictive Analytics (UMich HS650) 2.2 Example 2: minimizing a bivariate function
require("stats")
# Rosenbrock function N=4
f_rb <- function(x) { sum((100 * (x[1]^2 - x[2])^2) + (x[1] - 1)^2 , 100 * (x[3]^2 - x[4])^2 + (x[3] - 1)^2)
}
# initial guess for first minima 
initial_x_rb <- c(0, 0, 0, 0)
#initial condition, function, method
x_optimal_rb <- optim(initial_x_rb, f_rb, method="BFGS") # performs minimization
x_min_rb <- x_optimal_rb$par
# x_min contains the domain values where the (local) minimum is attained
x_min_rb   # critical point/vector
## [1] 0.9999755 0.9999517 0.9998969 0.9997934
# first extrema value of the objective function
x_optimal_rb$value
## [1] 1.130048e-08

1.1 Find the minimum of the contrained Mishra Bird function

\[ \begin {align*} f(x,y) = &\sin(y) e^{\left [(1-\cos x)^2\right]} + \cos(x) e^{\left [(1-\sin y)^2 \right]} + (x-y)^2 \\ &\text{Subject to} (x+5)^2 + (y+5)^2 < 25 \end {align*} \]

# Question 2
library("Rsolnp")
f_mb <- function(x,y){ # sin(y) * exp((1 - cos(x))^2) + cos(x) * exp((1 - sin(y))^2)+(x-y)^2
  sin(x[2]) * exp((1 - cos(x[1]))^2) + cos(x[1]) * exp((1 - sin(x[2]))^2)+(x[1]-x[2])^2
}
# constraint z1: (x + 5)^2 + (y + 5)^2 < 25
eqn1 <- function(x) { #(x+5)^2 + (y + 5)^2
  z1=(x[1]+5)^2 + (x[2]+5)^2
  return(c(z1))
}
# this is initial guess provides the global minima
soll_mb<-solnp(c(10,10), fun = f_mb, ineqfun = eqn1, ineqLB = -Inf, ineqUB = 25)
## 
## Iter: 1 fn: 5.1975    Pars:  2.84730 2.98609
## Iter: 2 fn: 3.7293    Pars:  -0.31540 -0.18946
## Iter: 3 fn: -2.0772   Pars:  -1.57019 -1.05530
## Iter: 4 fn: -105.7839     Pars:  -3.04970 -1.55482
## Iter: 5 fn: -106.7645     Pars:  -3.13025 -1.58214
## Iter: 6 fn: -106.7645     Pars:  -3.13025 -1.58214
## solnp--> Completed in 6 iterations

1.2 Find the global minimum

\[f(x,y,x)=-(x^3 +5y-2^z)\] \[ \begin {align*} &\text{Subject to: } \end {align*} \]

\[ \begin{cases} x -\frac{y}{2}+z^2 \leq 50\\ \mod(x, 4) + \frac{y}{2} \leq 1.5 \end{cases}\]

f <- function (x){
  -(x[1]^3 + 5*x[2] - 2^x[3])
}

# constraint z1:
# constraint z2:
# constraint z3:
ineq3 <- function(x){
  z1 = x[1] - (x[2]/2) + (x[3]^2)
  z2 = (x[1] %% 4) + (x[2]/2)
  z3 = x[3]
  return(c(z1, z2, z3))
}

lb = c(-1000,-1000,-1000)
ub = c(1000,1000,100)
lh <- c(-Inf, -Inf, -Inf) # tested lower bound and it doesn't change with c = -100 and c = -1000
uh <- c(50, 1.5, Inf)
# this is intial guess uses the maximum range within the given contraints
x0 <- c(49.75,-0.5,0) # setup: Try alternative starting-parameter vector (pars)
sol3 <- solnp(x0, fun=f, ineqfun=ineq3, ineqLB=lh, ineqUB=uh)   #, LB=lb, UB=ub)
## Warning in p0 * vscale[(neq + 2):(nc + np + 1)]: longer object length is
## not a multiple of shorter object length
## 
## Iter: 1 fn: -123130.8594  Pars:  49.75000 -0.50000  0      
## solnp--> Solution not reliable....Problem Inverting Hessian.
cat("Min is attained at: (", sol3$pars[1], ", ", sol3$pars[2], ", ", sol3$pars[1], ")\n")
## Min is attained at: ( 49.75 ,  -0.5 ,  49.75 )
cat("Min_f = ", sol3$values[length(sol3$values)])
## Min_f =  -123130.9