MathGroup Archive 2008

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

Search the Archive

Re: Plot vs NMaximize

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94241] Re: [mg94221] Plot vs NMaximize
  • From: Nikolaus Rath <Nikolaus at rath.org>
  • Date: Tue, 9 Dec 2008 06:55:13 -0500 (EST)
  • References: <200812081122.GAA15842@smc.vnet.net>

DrMajorBob <btreat1 at austin.rr.com> writes:
> Here's an example of using Plot to help FindMaximum:
>
> pts =.;
> f = Sin[2 x] Cos[3 x];
> p1 = Plot[f, {x, 0, 2 Pi}];
> xpts = First@Cases[p1, Line[pts : _] :> pts, Infinity];
> p2 = ListPlot[xpts];
> Show[p1, p2]
>
> (graphic omitted)
>
> max = SortBy[xpts, Last][[-1, 1]]
> FindMaximum[f, {x, max}]
>
> 5.31784
>
> {0.907858, {x -> 5.31789}}
>
> Plot got very close to the max in that interval, and FindMaximum uses
> the  result as an advanced start.

Interesting. I thought about the same thing, but I didn't expect that
it can be coded so easily.

> FindMaximum doesn't do it this way automatically, because it
> wouldn't always be best. You can never be certain, in fact, that
> Plot finds the global maximum.

Yes. But the same is true for NMaximize, so I do not understand why
the two functions use different methods when they (as I see it) give
the same result, only once as a graphic and once as a number.

Do you have an example where it would not be sensible to have
NMaximize find the same maximum that Plot shows?



Best,

   -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


  • Prev by Date: Re: Combinatorica documentation: Backtrack[]
  • Next by Date: Re: Plot vs NMaximize
  • Previous by thread: Plot vs NMaximize
  • Next by thread: Re: Plot vs NMaximize