# Gaps in simple plot

I am trying to recreate this which should be fairly straightforward with ParametricPlot, but wondering why this doesn't work:

With[{p = 20}, Plot[{(1 - x^(2 p))^(1/(2 p)), -(1 - x^(2 p))^(1/(2 p))},
{x, -1, 1}, AspectRatio -> Automatic, Frame -> True, GridLines ->
Automatic, PlotStyle -> {{Thickness[.005], Darker@Red}},
PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}]]


I have tried playing around with MaxRecursion, WorkingPrecision, PlotPoints etc. to no avail.

• You could use ContourPlot[] on the associated implicit equation instead. – J. M.'s discontentment Jun 26 '15 at 17:42

To get a function value of 10^-1 you need to evaluate the function at x = 1 - 10^-40 . That's a pretty fine grained step

Here is a cheap alternative:

f[x_, _] := {0, 0} /; (! -1 < x < 1.)
f[x_, p_] := (1 - x^p)^(1/p) {1, -1}

Plot[f[x, 40], {x, -1.5, 1.5}, AspectRatio -> Automatic]


(Plot[f[x, #], {x, -1.5, 1.5}, AspectRatio -> Automatic] & /@  Range[2, 40, 2]) // Show


• nice - thanks :) – martin Jun 26 '15 at 17:46

If you express your equation in polar coordinates, vertical lines won't be an issue:

x^(2 p) + y^(2 p) == 1 /. {x -> r Cos[θ], y -> r Sin[θ]} // PowerExpand

r^(2 p) Cos[θ]^(2 p) + r^(2 p) Sin[θ]^(2 p) == 1

With[{p = 20},
PolarPlot[(1/(Cos[θ]^(2 p) + Sin[θ]^(2 p)))^(1/(2 p)), {θ, 0, 2π}]
]


• great - yes, PolarPlot seems the most straightfoirward option - I was just wondering why my approach in the OP didn't work :) – martin Jun 26 '15 at 17:47
• Ah, I should learn to read! – Chip Hurst Jun 26 '15 at 17:48
• Ha! Good tip with PowerExand though - nice ref :) – martin Jun 26 '15 at 17:49

You could also add a UnitBox and expand the plot range just a little to catch the zeros:

With[{p = 20},
Plot[
UnitBox[x/2]*{(1 - x^(2 p))^(1/(2 p)), -(1 - x^(2 p))^(1/(2 p))},
{x, -1.0001, 1.0001},
AspectRatio -> Automatic, Frame -> True, GridLines -> Automatic,
PlotStyle -> {{Thickness[.005], Darker@Red}},
PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}
]
]


• neat trick! I'll remember that one :) – martin Jun 26 '15 at 21:26