Re: NIntegrate with Minimize

*To*: mathgroup at smc.vnet.net*Subject*: [mg53550] Re: [mg53549] NIntegrate with Minimize*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Tue, 18 Jan 2005 05:07:49 -0500 (EST)*References*: <200501170324.WAA05954@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

On 17 Jan 2005, at 04:24, Oz wrote: > Hiya, > > I'm having trouble performing a numerical integration that involves a > Minimize. I think it might have something to do with HoldAll, but am > not > sure how to fix it (couldn't find any actual solutions that worked in > the archives). Any help most appreciated. Here is a simplified version > of the code (the function and constraints I'm actually using are more > complicated): > > ff[a_] := First[Minimize[{x + a, 0 â?¤ x â?¤ 2}, {x}]] > NIntegrate[ff[a], {a, 0, 6}] > > Mathematica raises a Minimize::objv error, complaining that a+x > contains > a nonconstant expression independent of x, and so the NIntegrate fails. > Ideas? > > Thanks, > Oz > > > The thing to do is to restrict the domain of the function ff only to numeric quatntities as folows: ff[a_?NumericQ] := First[Minimize[{x + a, 0 <= x <= 2}, {x}]] NIntegrate[ff[a], {a, 0, 6}] 18. Andrzej Kozlowski Chiba, Japan http://www.akikoz.net/~andrzej/ http://www.mimuw.edu.pl/~akoz/

**References**:**NIntegrate with Minimize***From:*Oz <x_download@hotmail.com>