Placing a contour line at y when f(x)>=y
You can add a mesh line using the options MeshFunctions
and Mesh
:
ContourPlot[0.5 (x y - 4)^2, {x, 0, 3}, {y, 0, 3},
Contours -> {0, 1, 2, 3, 4},
PlotRange -> All,
ContourShading -> None,
MeshFunctions -> {# #2 &},
Mesh -> {{4}},
MeshStyle -> Black]
The square term and it being the minimum throws it off.
I think your best choice is to just solve your equation for when it is zero separately.
Solve[0.5 (x y - 4)^2 == 0, y]
(* {{y -> 4/x}, {y -> 4/x}} *)
Then plot and combine.
lp = Plot[4/x, {x, 0, 3}, PlotRange -> {{0, 3}, {0, 3}}, PlotStyle -> Black]
cp = ContourPlot[0.5 (x y - 4)^2, {x, 0, 3}, {y, 0, 3}, Contours -> {1, 2, 3, 4, 5, 6, 7}]
Show[cp,lp]
You can also generate just the 0 contour with the CounterPlot[ ]
function, taking advantage of your knowledge of the problem. You can merge this with the rest of the problem as per above.
ContourPlot[ (x y - 4) == 0, {x, 0, 3}, {y, 0, 3}]