0
$\begingroup$

Consider the parametric plot

(*prettier Manipulate available at the end*)
ParametricPlot[{Cos@\[Theta], Sin@\[Theta]}^0.01, {\[Theta], 0, \[Pi]/2}, 
PlotRange -> {{0, 1.1}, {0, 1.1}}, AspectRatio -> 1, Mesh -> All, MeshStyle -> Black]

which gives

plot of the parametric curve

The graph point $(0,1)$ at $\theta=\pi/2$ is not seen. Instead, the graph abruptly stops without reaching the y-axis.
Hot to resolve this?


Note that increasing PlotPoints doesn't work as the new points keep getting added between the leading and the ending points of the mesh. Also, the 'disconnection-from-y-axis' effect is apparent only for sufficiently low values of $n$ in the graph of $(\cos^n\theta,\sin^n\theta)$, in which case the curve gets progressively slower for $\theta>\pi/4$.

Prettier:

Manipulate[
 ParametricPlot[{Cos@\[Theta], Sin@\[Theta]}^n, {\[Theta], 
   0, \[Pi]/2}, 
  Epilog -> {Dashed, {Thin, Gray, Circle[]}, Text[n, {0.1, 1.05}]}, 
  GridLines -> {{1}, {1}}, PlotRange -> {{0, 1.1}, {0, 1.1}}, 
  AspectRatio -> 1, PlotTheme -> "Scientific", Mesh -> All, 
  MeshStyle -> Black, 
  Method -> "BoundaryOffset" -> False], {{n, 0.01}, 0.001, 10, 0.01, 
  Appearance -> "Labeled"}]
$\endgroup$
4
  • 1
    $\begingroup$ The problem is that your function is not very smooth. It makes a very fast change at Pi/2. MMA has trouble with such specials functions $\endgroup$ Dec 3, 2023 at 15:18
  • $\begingroup$ @DanielHuber The derivative's $\tan^{n-2}\theta$, so for small $n$ at $\pi/2$, it goes to zero, not blowup (as evident in the plot) - but I take your point (as for $\theta=\pi/2+\epsilon$, the abscissa is complex and graph abruptly ends) $\endgroup$
    – lineage
    Dec 3, 2023 at 15:40
  • $\begingroup$ @lineage: What you need it for? What is your final goal? If you want a parametric equation for a rectangle (or part of it) there are better equations. $\endgroup$ Dec 3, 2023 at 15:55
  • $\begingroup$ @azerbajdzan Just curious - recreational...puzzled me that it figured out $\theta=0$ but not $\pi/2$ $\endgroup$
    – lineage
    Dec 3, 2023 at 15:59

1 Answer 1

2
$\begingroup$

Adding WorkingPrecision -> 10 solves the problem. Also values for n in manipulate should be exact values.

Manipulate[
 ParametricPlot[{Cos@Abs@(\[Theta] + \[Pi]/4), 
    Sin@Abs@(\[Theta] + \[Pi]/4)}^n, {\[Theta], -\[Pi]/4, \[Pi]/4}, 
  Epilog -> {Dashed, {Thin, Gray, Circle[]}, Text[n, {0.1, 1.05}]}, 
  GridLines -> {{1}, {1}}, PlotRange -> {{0, 1.1}, {0, 1.1}}, 
  AspectRatio -> 1, PlotTheme -> "Scientific", Mesh -> All, 
  MeshStyle -> Black, WorkingPrecision -> 10, 
  Method -> "BoundaryOffset" -> False, 
  Exclusions -> None], {{n, 1/100}, 1/1000, 10, 1/100, 
  Appearance -> "Labeled"}]

enter image description here

In case a parametric plot of rectangle is needed there are better choices for the equations:

ParametricPlot[{2, 3}*{Abs@Sin@x Sin@x + Abs@Cos@x Cos@x, 
   Abs@Sin@x Sin@x - Abs@Cos@x Cos@x}, {x, 0, 2 \[Pi]}, 
 AspectRatio -> Automatic]

enter image description here

$\endgroup$
1
  • $\begingroup$ +1. That's strange though; reducing the precision makes the plot better? For me , WorkingPrecision->17 and upwards is worse off. $\endgroup$
    – lineage
    Dec 3, 2023 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.