Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Plotting objective function in FindMinimum
Replies: 1   Last Post: Jan 11, 2013 10:22 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Bob Hanlon

Posts: 892
Registered: 10/29/11
Re: Plotting objective function in FindMinimum
Posted: Jan 11, 2013 10:22 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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@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
>





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.