# Cassini oval plotting related isues

## 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.

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


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

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


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

• 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)]]}}; Jan 8 at 12:17
• @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]}] Jan 8 at 12:34
• Try Clear[Wall] first. It works for me. Jan 8 at 12:51
• 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] Jan 8 at 12:55

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]


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