       Re: NMinimize constraint bug

• To: mathgroup at smc.vnet.net
• Subject: [mg52858] Re: [mg52835] NMinimize constraint bug
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Wed, 15 Dec 2004 04:26:17 -0500 (EST)
• References: <200412141059.FAA24643@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On 14 Dec 2004, at 19:59, Joshua A. Solomon wrote:

> *This message was transferred with a trial version of CommuniGate(tm)
> Pro*
> In:={\$Version, \$ReleaseNumber}
> Out={5.0 for Mac OS X (June 10, 2003), 0}
>
> In:= NMinimize[{-Log[
> 1-p1]-Log[1-p2],LessEqual[.5,p1,p2,.9]},{p1,p2}]
>
> NMinimize::nrnum: The function value -0.57913-3.14159\\[ImaginaryI] is
> not a
> \
> real number at {p1,p2} = {2.46921,-0.214585}.
>
> NMinimize::nrnum: The function value -0.57913-3.14159\\[ImaginaryI] is
> not a
> \
> real number at {p1,p2} = {2.46921,-0.214585}.
>
> NMinimize::nrnum: The function value -0.57913-3.14159\\[ImaginaryI] is
> not a
> \
> real number at {p1,p2} = {2.46921,-0.214585}.
>
> etc.
>
>
> js
> --
> Joshua A. Solomon
> http://www.staff.city.ac.uk/~solomon
>

In Mathematica 5.0 you need to prevent the argument of Log from
becoming negative, even if your specified range of allowable values of
p1 and p2 does not allow this to happen. One way to do that is simply:

with 5.0

NMinimize[{(-Log[(1 - p1)^2] - Log[(1 - p2)^2])/2,
0.5 <= p1 <= p2 <= 0.9}, {p1, p2}]

{1.3862943609453324, {p1 -> 0.5, p2 -> 0.499999999912721}}

In Mathematica 5.1  NMinimize works better:

with 5.1

NMinimize[{-Log[1 - p1] - Log[1 - p2],
0.5 <= p1 <= p2 <= 0.9}, {p1, p2}]

{1.3862943609453635, {p1 -> 0.5,
p2 -> 0.4999999999127365}}

note that the answers are actually slightly different.

Andrzej Kozlowski
Chiba, Japan
http://www.akikoz.net/~andrzej/
http://www.mimuw.edu.pl/~akoz/

```

• Prev by Date: Re: Suse 9.2 + mathematica 5.0 problem (SOLVED)
• Next by Date: Re: problem getting the area under a parmetric curve
• Previous by thread: Re: NMinimize constraint bug
• Next by thread: Re: NMinimize constraint bug