You are on page 1of 2

Finding the Minimum of the Banana Function Using Monte Carlo Method

( )
2
2 2
f( x , y ) := ( 1 − x ) + y − x <= Expression defining the banana function

x 0 := −3 y 0 := 5 <= Initial guess

0 (
obj := f x 0 , y 0 ) obj = 32
0
<= Value of objective function at (x0, y0)

⎛1⎞
( )
<= location of minimum as found using the Mathcad
Minimize f , x 0 , y 0 = ⎜ ⎟
⎝1⎠ minimize function - this is the 'right answer'

f( 1 , 1 ) = 0 <= Minimum value of objective function

Make a list of 50 random (x,y) pairs

i := 0 .. 49 x := rnd( 6 ) − 3 random values -3 < x < 3


i

y := rnd( 7 ) − 5 random values -2 < y < 5


i

i (
r := f x , y
i i) <= Calculate values of objective function at random x,y points
( x , y , r)

Z := augment( r , augment( x , y ) ) Z := csort( Z , 0 )

0 1 2
Z= 0 0.056 1.063 0.901 <= Estimate of Minimum
1 0.408 0.51 -0.15
2 0.527 0.434 0.644

fstar := Z fstar = 0.056


0, 0

x star := Z x star = 1.063


0, 1

y star := Z y star = 0.901


0, 2

You might also like