7
$\begingroup$

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}}]]

Mathematica graphics

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

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

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]

Mathematica graphics

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

Mathematica graphics

| improve this answer | |
$\endgroup$
  • $\begingroup$ nice - thanks :) $\endgroup$ – martin Jun 26 '15 at 17:46
7
$\begingroup$

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π}]
]

enter image description here

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

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}}
 ]
]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ neat trick! I'll remember that one :) $\endgroup$ – martin Jun 26 '15 at 21:26

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.