2014-03-30 217 views
0

我最近一直在研究优化。我有兴趣说明积分从开始到最佳状态如何。 在ContourPlot教程,有使用结语一个例子:如何在MatheMatica中绘制Arrow箭头?

{min, {steps}} = 
Reap[NMinimize[{(x - 1)^2 + 100 (y - x^2)^2, 
x^2 + y^2 <= 1}, {{x, -1, -1/2}, {y, -1, -1/2}}, 
StepMonitor :> Sow[{x, y}], Method -> "DifferentialEvolution"]]; 

ContourPlot[(x - 1)^2 + 100 (y - x^2)^2, {x, -1, 1}, {y, -1, 1}, 
Contours -> 
Function[{lo, hi}, Exp[Range[0.01, Log[hi], (Log[hi] - 0.01)/10]]], 
RegionFunction -> Function[{x, y, z}, x^2 + y^2 <= 1], 
Epilog -> {Green, Line[steps], Red, Point[steps]}] 

但我想要的是剧情是这样的: http://upload.wikimedia.org/wikipedia/commons/7/79/Gradient_descent.png

箭头的箭头

非常感谢。

+0

你有箭头[]功能http://reference.wolfram.com/mathematica/ref/Arrow.html,但如果你想在每个箭头中显示箭头,你必须在几个箭头[]调用中拆分该行分割。 – siritinga

回答

0

Arrow[#]&/@Partition[steps,2,1] 

未经测试蒲式耳,应该让你接近更换Line[steps]