2
$\begingroup$

How do I plot a sampling of gradient vectors for fby using the vectorplot command? I’m confused how to use both these commands. enter image description here

$\endgroup$
6
$\begingroup$
f[x_, y_] := (4 x^2 + y^2) Exp[-x^2 - y^2]
VectorPlot[Evaluate@Grad[f[x, y], {x, y}], {x, -2, 2}, {y, -2, 2}]
Show[ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}], %]

enter image description here

EDIT

The default presentation of VectorPlot has evolved on Mathematica Version 12.1 .
Now it gives :

enter image description here

A lot of possibilities of tuning have been added too.

An overview of the state of the art :

f[x_, y_] := (4 x^2 + y^2) Exp[-x^2 - y^2]
VectorPlot[Evaluate@Grad[f[x, y], {x, y}], {x, -2, 2}, {y, -2, 2}, 
 PlotLegends -> Automatic]
Show[ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}, 
  PlotLegends -> Automatic, ContourLabels -> True], %]  

enter image description here

$\endgroup$
2
  • $\begingroup$ How would you find the exact critical points? $\endgroup$ – calculusbuff39 Oct 18 '18 at 3:09
  • $\begingroup$ @calculusbuff39 Try FindRoot with initial guess read of from the plots. $\endgroup$ – Henrik Schumacher Oct 18 '18 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.