当用mathematica作梯度矢量图时......
首先假设一函数为
1 | VectorPlot[Grad[x^2 + y^2, {x, y}], {x, -3, 3}, {y, -3, 3}] |
运行结果中将无任何图像,如图所示

为找到问题所在,先将梯度计算出再画图进行尝试

由此可见VectorPlot并无异常,可能是Grad得到的结果不是我们期待的
对第一个代码进行追踪
可见其结果并不是我们所期待的那样。为解决此问题对Grad使用Evaluate
1 | VectorPlot[Evaluate@Grad[x^2 + y^2, {x, y}], {x, -3, 3}, {y, -3, 3}] |
这样一来就得到了所期待的结果(如下图)。

mathematica 中对 Evaluate 的介绍
Evaluate[expr] causes expr to be evaluated even if it appears as the argument of a function whose attributes specify that it should be held unevaluated.
Details
You can use Evaluate to override HoldFirst etc. attributes of built-in functions.
Evaluate only overrides HoldFirst etc. attributes when it appears directly as the head of the function argument that would otherwise be held.
其实还是没有理解为什么 Grad 需要 Evaluate 对其进行计算ψ(._.
)>,为什么 Grad 在 Vector 内就没有计算到

留个坑,以后再说... ╥﹏╥
更新
经过他人指点,这是由于它先计算了函数的值,从而对一个常数函数微分,所以只有 0 这一个值。
如此计算的原因是,Plot 系列函数的 HoldAll 属性控制了在最后一步才代入计算。因而需要用 Evaluate 来控制计算顺序。