Re: Re: Numerical Optimization involving equation solving

*To*: mathgroup at smc.vnet.net*Subject*: [mg56035] Re: [mg56023] Re: [mg55969] Numerical Optimization involving equation solving*From*: Bob Hanlon <hanlonr at cox.net>*Date*: Thu, 14 Apr 2005 08:54:28 -0400 (EDT)*Reply-to*: hanlonr at cox.net*Sender*: owner-wri-mathgroup at wolfram.com

It is better to use NumericQ rather than NumberQ to accept expressions including built-in constants const=ToExpression/@Select[Names["*"], MemberQ[Attributes[#],Constant]&] {Catalan, Degree, E, EulerGamma, Glaisher, GoldenRatio, Khinchin, MachinePrecision, Pi} NumberQ/@const {False,False,False,False,False,False,False,False,False} NumericQ/@const {True,True,True,True,True,True,True,True,True} Bob Hanlon > > From: Christopher Purcell <christopherpurcell at mac.com> To: mathgroup at smc.vnet.net > Date: 2005/04/13 Wed AM 01:11:12 EDT > To: mathgroup at smc.vnet.net > Subject: [mg56035] [mg56023] Re: [mg55969] Numerical Optimization involving equation solving > > Try using the pattern test ?NumberQ in your definition of the function > f. > as in: > > f[x_?NumberQ]:=(stuff;Return[ans]; > > You can learn more about this with ?PatternTest. > > > > Christopher Purcell > Sensors & Actuators Group > DRDC-Atlantic, 9 Grove St., PO Box 1012, > Dartmouth NS B2Y 3Z7 Canada > Work E-mail chris.purcell at drdc-rddc.gc.ca > Work Tel 902-426-3100 x389 Fax 902-426-9654 > Home Tel 902-464-9248 > Home E-mail christopherpurcell at mac.com > AIM/iChatAV: cffrc > > On Apr 12, 2005, at 6:26 AM, Brian Rogers wrote: > > > I need to optimize a function of one variable, say > > f[x_]:=(stuff;Return[ans];). Computing the value of f requires solving > > a (non-linear) system of equations that depend on x, and using this > > solution to compute some other things. > > > > Now, evaluating f at a numerical value of x works just fine, and I can > > even plot f (using Plot[f[x],{x,0,1}]) and eyeball the optimum. By the > > way, f is a very well behaved function--it is typically smooth and > > globally convex. However, what I really want to do is use FindMinimum > > (or NMinimize) to numerically return the optimum. When I use either of > > these built-in functions, they crash. I believe that they are first > > trying to evaluate f[x] symbolically--which would understandably cause > > it to crash because the system of equations doesn't have a closed form > > solution in x. > > > > I've tried using the "Compiled" option with no luck. How can I force > > FindMinimum to use a purely numerical procedure to optimize my > > function? > > > > Any help is greatly appreciated, and please copy any reply to > > brifry at gmail.com. > > Thanks! > > > >