From: Nick Grishin on
(* 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)

From: Chris Chiasson on
So, are you saying that the bug is example number one or number two?

On 11/6/06, Nick Grishin <grishin(a)chop.swmed.edu> 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)
>
>


--
http://chris.chiasson.name/

From: Andrzej Kozlowski on

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


From: harlekin on
That works at Version 5.1:

NMaximize[Integrate[-t^3, {t, 0, x}], x] or NMaximize[NIntegrate[-t^3,
{t, 0, x}], x]

OK, it's not exactly your problem, but the real problem is
Integrate/NIntegrate, i think.

Maybe that helps...



Nick Grishin schrieb:

> (* 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)

From: Andrzej Kozlowski on

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


One correct way to do this kind of thing would be:

func [x_?NumericQ] := NIntegrate[t^3, {t, 0, x}]

Then


Chop[NMinimize[func[x], x]]


{0, {x -> -8.478781415049459*^-9}}

and

NMaximize[func[x], x]
NMaximize::"cvdiv" : "Failed to converge to a solution. The function
may be unbounded.

{8.16355648507784698932167375`15.954589770191005*^537, {x ->
-4.250938758824719*^134}}


both of which at least make sense.

Andrzej Kozlowski
Tokyo, Japan