4
$\begingroup$

PART 1

The parametric equation mentioned in the webpage, Eggs, melons, and peanuts - Cassini Oval, for the Cassini oval is given by

Wall[{a_, b_}, 
   t_] := {Cos[t]*Sqrt[a^2 Cos[2*t] + Sqrt[(b^4 - a^2*Sin[2*t]^2)]], 
   Sin[t]*Sqrt[a^2 Cos[2*t] + Sqrt[(b^4 - a^2*Sin[2*t]^2)]]};

where, c = a^2 Cos[2*t] \[PlusMinus] Sqrt[(b^4 - a^2*Sin[2*t]^2)];

Note: b cannot be 0

  1. When a < b the parameter t ranges from 0 to 2 Pi
  2. When a = b the curve reduces to r^2 = a^2 Cos (2 t)
  3. When a > b each loop is defined in two parts, one using the positive version of c above, and the other using the negative version. The parameter t ranges from - 0.5 ArcSin (b^2/a^2) to 0.5 ArcSin (b^2/a^2).

While plotting, for b>a, the results are coming as expected. However, for b<a, incomplete circles are forming even if I'm using the 3rd case as mentioned above. enter image description here

I'm making a mistake in defining the loops by taking +ve and -ve values of c, I guess. Here is my sample code using the -ve value of c for plotting

Wall1[{a_, b_}, 
  t_] := {Cos[t]*
   Sqrt[-(a^2 Cos[2*t] - Sqrt[(b^4 - a^2*Sin[2*t]^2)])], 
  Sin[t]*Sqrt[-(a^2 Cos[2*t] - Sqrt[(b^4 - a^2*Sin[2*t]^2)])]}

ParametricPlot[{Wall[{1, Sqrt[1.35]}, t], Wall1[{1, Sqrt[0.5]}, t], 
  Wall[{1, Sqrt[0.5]}, t]}, {t, 0, 2 \[Pi]}, 
 PlotStyle -> {Red, Darker[Green], Blue}]

enter image description here

Please help solve this issue of plotting the graph using ParametricPlot. The desired graphs should come as this enter image description here

PART 2

In Cartesian Co-ordinates, the region is defined by

\[GothicCapitalR]0[x_, y_, a_, 
   b_] := ((x - a)^2 + y^2) ((x + a)^2 + y^2) - b^2;

However, the ParametricPlot and ContourPlot give slightly different results as shown below for b>a.

Show[ParametricPlot[Wall1[{1, Sqrt[1.375]}, t], {t, 0, 2 \[Pi]}, 
  PlotStyle -> {Red}], 
 ContourPlot[\[GothicCapitalR]0[x, y, 1, Sqrt[1.35]] == 0, {x, -2, 
   2}, {y, -1, 1}]]

enter image description here

Why is this happening? And how to resolve this issue and get the same shape?

Please help me out.

$\endgroup$
4
  • $\begingroup$ Why don't you just plot both branches, namely the one with + and the one with –? Wall[{a_, b_}, t_] := Wall[{a, b}, t] = FullSimplify@{{Cos[t]*Sqrt[a^2 Cos[2*t] + Sqrt[(b^4 - a^2*Sin[2*t]^2)]], Sin[t]*Sqrt[a^2 Cos[2*t] + Sqrt[(b^4 - a^2*Sin[2*t]^2)]]},{Cos[t]*Sqrt[a^2 Cos[2*t] - Sqrt[(b^4 - a^2*Sin[2*t]^2)]], Sin[t]*Sqrt[a^2 Cos[2*t] - Sqrt[(b^4 - a^2*Sin[2*t]^2)]]}}; $\endgroup$
    – Domen
    Jan 8 at 12:17
  • $\begingroup$ @Domen, I did not know that I could define a function like this. Thank you. However, it doesn't work while plotting the graph. I mean the desired plot is not coming. ParametricPlot[{Wall[{1, Sqrt[0.9]}, t]}, {t, 0, 2 \[Pi]}] $\endgroup$
    – user444
    Jan 8 at 12:34
  • $\begingroup$ Try Clear[Wall] first. It works for me. $\endgroup$
    – Domen
    Jan 8 at 12:51
  • $\begingroup$ I'm using Mathematica 12.0 on a Linux system. Could that be a reason for not geeting the grapph? Because, I have used Clear[Wall] $\endgroup$
    – user444
    Jan 8 at 12:55

1 Answer 1

5
$\begingroup$

You need to plot both branches, the one with $+$ and the one with $-$ inside square root. You can do this with one ParametricPlot by simply plotting both of the branches at the same time.

Clear[Wall];
Wall[{a_, b_}, t_] := Module[{
    c1 = a^2 Cos[2*t],
    c2 = Sqrt[(b^4 - a^2*Sin[2*t]^2)]},
    {
     {Cos[t], Sin[t]} Sqrt[c1 + c2],
     {Cos[t], Sin[t]} Sqrt[c1 - c2]
    }
   ];

ParametricPlot[
 Table[Wall[{1, b}, t], {b, 0.2, 1.5, .2}], {t, -2 Pi, 2 π}, 
 PlotHighlighting -> None, PlotPoints -> 200]

enter image description here

Note that you may need to increase PlotPoints even further for smaller bs.

As for the discrepany with ContourPlot, two issues:

  1. You are using $b=1.375$ in ParametricPlot and $b=1.35$ in ContourPlot.
  2. There is probably a mistake somewhere in the derivation on the page, mixing $b$ and $b^2$. The curves match if you use $b^2$ instead of $b$ in ContourPlot:
R0[x_, y_, a_, b_] := ((x - a)^2 + y^2) ((x + a)^2 + y^2) - b^2;
With[{b = 1.375},
 Show[ParametricPlot[Wall[{1, Sqrt[b]}, t], {t, 0, 2 π}], 
  ContourPlot[R0[x, y, 1, b] == 0, {x, -2, 2}, {y, -1, 1}, 
   ContourStyle -> {Red, Dashed}]]]

enter image description here

$\endgroup$

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.