Re: Plotting objective function in FindMinimum

• To: mathgroup at smc.vnet.net
• Subject: [mg129404] Re: Plotting objective function in FindMinimum
• From: Bob Hanlon <hanlonr357 at gmail.com>
• Date: Fri, 11 Jan 2013 22:22:24 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net
• References: <20130111024036.F168D68E9@smc.vnet.net>

```f[x_] = x Cos[x];

pts = Reap[fm = FindMinimum[f[x], {x, 2},
EvaluationMonitor :>
Sow[{x, f[x]}]]][[-1, 1]]

{{2., -0.832294}, {3., -2.96998}, {4.72069,
0.0391653}, {3.37006, -3.28249}, {3.43491, -3.28821}, {3.42548, \
-3.28837}, {3.42562, -3.28837}, {3.42562, -3.28837}}

fm

{-3.28837, {x -> 3.42562}}

markers = Style[ToString[#], 18] & /@ Range[Length[pts]];

Show[
Plot[f[x], {x, 0, 4.8},
PlotStyle -> Lighter[Blue, .7]],
ListPlot[List /@ pts,
PlotMarkers -> markers],
Graphics[{
Purple,
Line[pts],
Red,
AbsolutePointSize[4],
Point[pts[[-1]]]}],
Frame -> True,
Axes -> False,
PlotRange -> All]

Bob Hanlon

On Thu, Jan 10, 2013 at 9:40 PM,  <pguerron at gmail.com> wrote:
> Hi,
>
> I want to track the progress of the minimizer FinMinimum. Is there a way to plot the objective function for each iteration of the minimization routine?
>
> Thanks,
>
> Pablo
>

```

• Prev by Date: Modern Differential Geometry for Mathematica 9
• Next by Date: Re: wrong result when computing a definite integral
• Previous by thread: Plotting objective function in FindMinimum
• Next by thread: Re: Plotting objective function in FindMinimum