Re: Plot vs NMaximize
- To: mathgroup at smc.vnet.net
- Subject: [mg94240] Re: [mg94221] Plot vs NMaximize
- From: Nikolaus Rath <Nikolaus at rath.org>
- Date: Tue, 9 Dec 2008 06:55:02 -0500 (EST)
- References: <13842004.1228737086065.JavaMail.root@m02>
"David Park" <djmpark at comcast.net> writes:
>> It seems to me that it is significantly faster *and* more accurate to
>> determine global maxima by plotting the function and looking for the
>> positions on the plot than to use NMaximize: in all the cases that
>> I've encountered recently, NMaximize got stuck in local extrema (which
>> was very easy to see when looking at the plot).
>>
>> I know that global optimization is a very difficult problem, but I do
>> not understand why Plot[] does not suffer from the same problem. If
>> Plot[] is able to generate a plot where I can see the position of the
>> global maximum in a second, why does NMaximize need several seconds to
>> get stuck in some local maxima? Shouldn't it be able to make use of
>> the same algorithms that Plot[] uses?
>
> How about a specific example where NMaximize gets stuck but you can easily
> see the maximum from a plot?
Try this one:
f[x_] := Sin[2 \[Pi] x] + 10 Sin[(2 \[Pi] x)/30]
Plot[f[x], {x, 0, 50}]
NMaximize[{f[x], x >= 0 && x < 50}, x]
this gives me a maximum at {0.988032, {x -> 29.8451}}.
> In the case a 2D function I can envision a dynamic display that would hav=
e a
> background contour plot of the function and a movable rectangle with
> adjustable side lengths that would pick a certain region, and then NMaxim=
ize
> would be used within the region to give a higher precision answer. So why
> not combine the two in that way?
Well, I realized the same thing. But the point of my question is: why
do I have to set up the above manually?
Since I could also parse the Graphics[] object directly to find the
local maximum, there isn't a need for a dynamic display at all. But
why doesn't NMaximize already do that? (It should of course not parse
the Graphic[] but make use of the data that was used to generate it).
-Nikolaus
--
=C2=BBIt is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that.=C2=AB
-J.H. Hardy
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C