Re: weird NMaximize behaviour

• To: mathgroup at smc.vnet.net
• Subject: [mg92162] Re: weird NMaximize behaviour
• From: dh <dh at metrohm.ch>
• Date: Mon, 22 Sep 2008 05:25:45 -0400 (EDT)
• References: <gat9qm\$ejo\$1@smc.vnet.net> <200809190916.FAA15056@smc.vnet.net> <gb2dra\$bct\$1@smc.vnet.net>

```
Hi Andrzej,

I agree, Mathematica must have some mean to decide on which side of the minimum

the largest value, compatible with the conditions, lies.

Daniel

For NMaximize[{(x - i)^2, -2 <= x <= 2}, {x}] the starting value for the

uphill search is taken somwhere between 0..1

Andrzej Kozlowski wrote:

> I don't think the answer can be as simple as that. Note that:

>

> Table[First[NMaximize[{(x - i)^2, -2 <= x <= 2}, {x}]] -

>    First[NMaximize[{(x - i)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x,

> y}]], {i, 0,

>    10}]

> {0., 8., 0., 0., 0., 0., 0., 0., 0., 0., 0.}

>

> Andrzej Kozlowski

>

>

> On 19 Sep 2008, at 18:16, dh wrote:

>

>>

>> Hi Andrzej,

>>

>> We do not know what method is chosen by the default Method-

>>> "Automatic",

>> but it seems to me that some "up hill" method is invoked. Starting at

>>

>> some point x0>1, the algorithm will then go towards larger x until

>>

>> reaching the border of the region.

>>

>> To fix this, we need to choose a method that does not simply go uphill

>>

>> but tries to find a global maximum, e.g. "SimulatedAnnealing" or

>>

>> "DifferentialEvolution". E.g. "SimulatedAnnealing"  gives:

>>

>> {9.,{x->-2.,y->0.999067}}

>>

>> Daniel

>>

>>

>>

>>

>>

>> Andrzej Kozlowski wrote:

>>

>>> I have just encountered strange behaviour by NMaximize (which has

>>> been

>>> ruining a demonstration I have been working on):

>>> This is fine:

>>> NMaximize[{(x - 1)^2, -2 <= x <= 2}, {x}]

>>> {9., {x -> -2.}}

>>> but this definitely is not:

>>> NMaximize[{(x - 1)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}]

>>> {1., {x -> 2., y -> 0.87904}}

>>> The objective function s independent of y, yet NMaximize seems to go

>>> off on some wild goose chase and ends up with a very poor "maximum".

>>> This does not happen here:

>>> NMaximize[{(x - 2)^2, -2 <= x <= 2}, {x}]

>>> {16., {x -> -2.}}

>>> NMaximize[{(x - 2)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}]

>>> {16., {x -> -2., y -> -0.980305}}

>>> Kind of weird.

>>> Andrzej Kozlowski

>>

>>

>>

>>

>> --

>>

>>

>>

>> Daniel Huber

>>

>> Metrohm Ltd.

>>

>> Oberdorfstr. 68

>>

>> CH-9100 Herisau

>>

>> Tel. +41 71 353 8585, Fax +41 71 353 8907

>>

>> E-Mail:<mailto:dh at metrohm.com>

>>

>> Internet:<http://www.metrohm.com>

>>

>>

>>

>

>

--

Daniel Huber

Metrohm Ltd.

Oberdorfstr. 68

CH-9100 Herisau

Tel. +41 71 353 8585, Fax +41 71 353 8907

E-Mail:<mailto:dh at metrohm.com>

Internet:<http://www.metrohm.com>

```

• Prev by Date: Re: Re: data source for demonstration
• Next by Date: Re: Functional programming? (RPN -v- Algebraic)
• Previous by thread: Re: Re: weird NMaximize behaviour
• Next by thread: blurry ellipse