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[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. Andrzej Kozlowski Chiba, Japan http://www.akikoz.net/~andrzej/ http://www.mimuw.edu.pl/~akoz/
- References:
- NMinimize constraint bug
- From: "Joshua A. Solomon" <J.A.Solomon@city.ac.uk>
- NMinimize constraint bug