MathGroup Archive 2005

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

Search the Archive

Re: NIntegrate with Minimize

Woops, sorry. The code is

ff[a_] := First[Minimize[{x + a, 0 <= x <= 2}, {x}]]
NIntegrate[ff[a], {a, 0, 6}]

and the problem is that it can't do the Minimize symbolically, which it
seems to try to do before putting the value of 'a' in.

I have, since posting, found out a way to work around it (thanks to Andrzej
Kozlowski), namely putting in ?NumericQ next to the variable in the function

ff[a_?NumericQ] := First[Minimize[{x + a, 0 <= x <= 2}, {x}]]
NIntegrate[ff[a], {a, 0, 6}]


Kind Regards,

-----Original Message-----
From: DrBob [mailto:drbob at] 
To: mathgroup at
Subject: [mg53556] Re: [mg53549] NIntegrate with Minimize

Try posting that in InputForm, so that we can see the code.


On Sun, 16 Jan 2005 22:24:06 -0500 (EST), Oz <x_download at> 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

DrBob at

  • Prev by Date: Re: about PATTERNS
  • Next by Date: Re: Mathematica, LabView and I/O devices
  • Previous by thread: Re: NIntegrate with Minimize
  • Next by thread: about PATTERNS