4
$\begingroup$

I'm trying to plot a couple of $l^p$ circles, but when $p=\infty$ its not quite showing up (the max one in the code below):

ContourPlot[{Abs[x] + Abs[y] == 1, x^2 + y^2 == 1, x^4 + y^4 == 1, 
  Max[Abs[x], Abs[y]] == 1}, {x, -1, 1}, {y, -1, 1}]

Is there a way to plot this (preferably not telling Mathematica that it's a square)?

$\endgroup$
5
$\begingroup$

You need to get sampling points on both sides of the curve for it to show up with ContourPlot.

ContourPlot[{Abs[x] + Abs[y] == 1, x^2 + y^2 == 1, x^4 + y^4 == 1, 
  Max[Abs[x], Abs[y]] == 1}, {x, -1.05, 1.05}, {y, -1.05, 1.05}(*, Exclusions -> None*)]

Mathematica graphics

Add the option Exclusions -> None to remove the gaps in the corners. Mathematica is thinking there is a discontinuity, but it's wrong.

Addendum

With a little trickery, you can use Norm[v, p] and make a slider run between Infinity and 1:

Manipulate[
 ContourPlot[
  Norm[{x, y}, Limit[1/pp, pp -> p]], {x, -1.05, 1.05}, {y, -1.05, 1.05}],
 Row[{Control[{p, 0, 1}], 
   InputField[Dynamic[Limit[1/pp, pp -> p], If[# >= 1, p = 1/#] &], 
    Appearance -> "Frameless"]}, " "]
 ]

$\endgroup$
5
$\begingroup$
RegionPlot[Evaluate[Norm[{x, y}, #] <= 1 & /@ {1, 2, 4, Infinity}], {x, -1, 1}, {y, -1, 1}]

Mathematica graphics

Add the option PlotStyle -> {None, None, None, None}] to get

Mathematica graphics

$\endgroup$

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.