Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NMinimize constraint bug

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

On 14 Dec 2004, at 22:01, Andrzej Kozlowski wrote:

>
> On 14 Dec 2004, at 19:59, Joshua A. Solomon wrote:
>
>> In[1]:={$Version, $ReleaseNumber}
>> Out[1]={5.0 for Mac OS X (June 10, 2003), 0}
>>
>> In[2]:= 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.
>>
>> Comments?
>>
>> 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.
>
>


Actually, in 5.0 it may be better to use Abs instead of squaring the 
arguments of logs.

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


  • Prev by Date: Two DatabaseLink issues
  • Next by Date: GUIKit - ScrollPane Tables within Wizard
  • Previous by thread: Re: NMinimize constraint bug
  • Next by thread: Re: NMinimize constraint bug