From: Andrzej Kozlowski on 8 Nov 2006 06:45 On 6 Nov 2006, at 19:05, Andrzej Kozlowski wrote: > > On 6 Nov 2006, at 16:52, Nick Grishin wrote: > >> (* does not work *) >> func = Hold[NIntegrate[t^3, {t, x, 0}]]; >> NMaximize[func, x] >> >> (* works *) >> func = Hold[NIntegrate[t^3, {t, 0, x}]]; >> NMinimize[func, x] >> >> $Version >> 5.2 for Microsoft Windows (June 20, 2005) >> > > A bug in NMaximize? Why? It behaves exactly as it should do with > this kind of input. The problem is with MMinimize, because you > when you give it nonsensical input it actually produces output, > which unfortunately (by sheer accident), looks as if it might be > right. But it is nonssense nonetheless (nonsense in - > nonsense > out) nonsensical, and to convince you of it I will slightly change > your input: > > func = Hold[NIntegrate[t^3, {t, 10, x}]]; > > > NMinimize[func, x] > > > {-2500.0000000000005, {x -> -0.0002833987269403981}} > > Now, does this look like it "works"? > > Andrzej Kozlowski I have to admit that my example was pointless; it does also "work" just as much as your example works, although it should not. I agree that seeing this give what seem to be "right answers" might convince one that using Hold in this way is the right thing to do, but it is not. If there is a bug than it is in NMinimize and not in NMaximize and Hold should never be used in this sort of situation. Andrzej Kozlowski
From: Nick Grishin on 8 Nov 2006 06:48
> On 6 Nov 2006, at 19:05, Andrzej Kozlowski wrote: > >> >> On 6 Nov 2006, at 16:52, Nick Grishin wrote: >> >>> (* does not work *) >>> func = Hold[NIntegrate[t^3, {t, x, 0}]]; >>> NMaximize[func, x] >>> >>> (* works *) >>> func = Hold[NIntegrate[t^3, {t, 0, x}]]; >>> NMinimize[func, x] >>> >>> $Version >>> 5.2 for Microsoft Windows (June 20, 2005) >>> >> >> A bug in NMaximize? Why? It behaves exactly as it should do with this kind >> of input. The problem is with MMinimize, because you when you give it >> nonsensical input it actually produces output, which unfortunately (by >> sheer accident), looks as if it might be right. But it is nonssense >> nonetheless (nonsense in - > nonsense out) nonsensical, and to convince >> you of it I will slightly change your input: >> >> func = Hold[NIntegrate[t^3, {t, 10, x}]]; >> >> >> NMinimize[func, x] >> >> >> {-2500.0000000000005, {x -> -0.0002833987269403981}} >> >> Now, does this look like it "works"? >> >> Andrzej Kozlowski > > > I have to admit that my example was pointless; it does also "work" just as > much as your example works, although it should not. I agree that seeing this This I understand. n |