Clear[f];
f[x_, y_] = Exp[(-x^2 - 2*y^2)/10^4]
t1 = ContourPlot[f[x, y], {x, -1, 1}, {y, -1, 1}, PlotPoints -> 50,
ContourShading -> False]
fx[x_, y_] = D[f[x, y], x]
fy[x_, y_] = D[f[x, y], y]
a = 1; b = 1; lamda = 0.01;
Do[u = a + lamda*fx[a, b]/Sqrt[(fx[a, b])^2 + (fy[a, b])^2];
v = b + lamda*fy[a, b]/Sqrt[(fx[a, b])^2 + (fy[a, b])^2];
c[n] = u; d[n] = v; a = u; b = v, {n, 200}]
data = Table[{c[n], d[n]}, {n, 200}];
t2 = ListPlot[data]
Show[t1, t2]
老公加油!
温馨提示:答案为网友推荐,仅供参考