Message Boards Message Boards

1
|
5337 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Show the high of the levels in ContourPlot?

Posted 6 years ago

I have looked up in the Mathematica Documention Center the answerfor my problem but unfortunatteny they make available only a few examples and details. My problem is to plot a contour of the function f(x,y)= Exp[-y^2 - x^4/4 + x^2], indicating the height of each level and putting a point (or a cross) on the two local maximum at (-2^(1/2),0) and at (2^(1/2),0)( which is "e") .Besides these I would like to color the zero level differenttily of the others.

thank you. Ana Luiza

Plot3D[Exp[-y^2 - x^4/4 + x^2], {x, -2.5`, 2.5`}, {y, -2.5`, 2.5`}]
ContourPlot[
 f[x, y] == {0.5, 0.7, 1.5, 2.0, 2.71}, {x, -2.5`, 2.5`}, {y, -2.5`, 
  2.5`}]
POSTED BY: Ana Squadri

Hello Ana Luiza, first, locate the maxima:

f[x_, y_] := Exp[-y^2 - x^4/4 + x^2];
Plot3D[f[x, y], {x, -2.5`, 2.5`}, {y, -2.5`, 2.5`}]
Zone = Polygon[{{-2.5, -2.5}, {-2.5, 2.5}, {2.5, 2.5}, {2.5, -2.5}}];
Sup1 = ArgMax[f[x, y], {x, y} \[Element] Zone];
Sup2 = {x, y} /. Last@FindMaximum[f[x, y], {x, -1}, {y, 0}];

(AgMax finds a single max).

Then plot

Show[ContourPlot[f[x, y], {x, -2.5`, 2.5`}, {y, -2.5`, 2.5`}, 
  Contours -> {0.5, 0.7, 1.5, 2.0, 2.71}, ContourLabels -> True], 
 Graphics[{Green, PointSize[Large], Point[Sup1]}]

 , Graphics[{Red, PointSize[Large], Point[Sup2]}]]
POSTED BY: Claude Mante
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract