# Plotting in the “Manipulate” function - simple coding

Hello Mathematica community, my name is Preston!

I have a real quick question that should be easy to answer. Alright, so for a research project that I'm involved it at my university, I need to illustrate the outline of a Cassini Oval using something I've been calling "concentric circles" - but that doesn't really matter. I've decided to use Mathematica in my research. I used the "Manipulate" function in order to illustrate what these "concentric circles" would do as their radii varied over a specific interval. Here's the code for that:

Manipulate[
Graphics[{Circle[{-1, 0}, H], Circle[{1, 0}, 1.2/H]},
Axes -> True], {H, Sqrt[1.2 + 1] - 1, Sqrt[1.2 + 1] + 1}]

That is all fine and good, and it does exactly what I want. However, I really need to somehow plot the curve of the following function in the Manipulate:

[(x+1)^2+y^2]*[(x-1)^2+y^2]=(1.2)^2

So, basically, as the manipulator runs, I want the "concentric circles" to do what they do, but I want the function I just listed to just sit still. The idea is that as the "concentric circles" change over the interval defined for $H$, their intersection will outline a Cassini Oval (the equation above).

I would greatly appreciate any help. Thanks! Also, what I'm trying to do may be illustrated in the following code:

x = Table[{(-1 + H^4)/(4 H^2), Sqrt[1 - H^2 + (2 H^2 (-1 + H^4))/(4 H^2) -
H^2 ((-1 + H^4)/(4 H^2))^2]/H}, {H, 1, 1 + Sqrt[2], 0.01}];

x1 = Table[{(-1 + H^4)/(4 H^2), -(Sqrt[1 - H^2 + (2 H^2 (-1 + H^4))/(4 H^2) -
H^2((-1 + H^4)/(4 H^2))^2]/H)}, {H, 1, 1 + Sqrt[2], 0.01}];

x2 = Table[{-((-1 + H^4)/(4 H^2)), Sqrt[1 - H^2 + (2 H^2 (-1 + H^4))/(4 H^2) -
H^2 ((-1 + H^4)/(4 H^2))^2]/H}, {H, 1, 1 + Sqrt[2], 0.01}];

x3 = Table[{-((-1 + H^4)/(4 H^2)), -(Sqrt[1 - H^2 + (2 H^2 (-1 + H^4))/(4 H^2) -
H^2 ((-1 + H^4)/(4 H^2))^2]/H)}, {H, 1, 1 + Sqrt[2], 0.01}];

m =
Manipulate[
Graphics[{Green, Circle[{1, 0}, 1/H], Blue, Circle[{-1, 0}, H],
Black, {BezierCurve[x]}, {BezierCurve[x1]},
{BezierCurve[x2]}, {BezierCurve[x3]}}, Axes -> True], {H, 1/(Sqrt[2] + 1),
Sqrt[2] + 1}]

This is something I did for a trivial Cassini Oval with constant product equal to 1. It sort of does what I want, but it's way to complicated and glitchy. I want to know if a more evolved code is possible.

-
By the way, "concentric" means having the same centre, which your circles don't. I suggest choosing a different terminology :-) –  Simon Woods Jan 16 '14 at 21:51
Welcome to Mathematica.SE! Can you edit your profile and set your name, so it's something easier to remember than user11781? –  Szabolcs Jan 16 '14 at 23:26

You can use ContourPlot to draw the function and Show to combine it with the other graphics:

With[{p =
ContourPlot[((x + 1)^2 + y^2)*((x - 1)^2 + y^2) == (1.2)^2,
{x, -3, 3}, {y, -3, 3}, Frame -> False]},
Manipulate[
Show[p, Graphics[{Circle[{-1, 0}, H], Circle[{1, 0}, 1.2/H]},
Axes -> True]], {H, Sqrt[1.2 + 1] - 1, Sqrt[1.2 + 1] + 1}]]

To show the Cassini Oval being drawn as you move the slider, I would suggest using a ParametricPlot. First use Solve to obtain a parametric description of the curve:

sol = {x, y} /. Solve[{
((x + 1)^2 + y^2) == h^2,
((x - 1)^2 + y^2) == (1.2/h)^2},
{x, y}];

Then put a parametric plot of sol into the Manipulate.

Manipulate[
ParametricPlot[sol, {h, Sqrt[1.2 + 1] - 1, H},
Epilog -> {Circle[{-1, 0}, H], Circle[{1, 0}, 1.2/H],
PointSize[Large], Point[sol /. h -> H]},
PlotRange -> 4, PlotStyle -> Thick],
{H, $MachineEpsilon + Sqrt[1.2 + 1] - 1, Sqrt[1.2 + 1] + 1}] - Thank you Simon! This is very helpful! – user11781 Jan 16 '14 at 18:19 Also, and this may be stretching, but is it possible to create an animation where the "concentric circles" outline the shape of the Cassini Oval with their intersections as$H$varies over its interval? I.E as$H=1$maybe 1/3 of the Cassini Oval is outlined, when$H=\sqrt{1.2+1}+1\$ the oval is completely outlined. –  user11781 Jan 16 '14 at 18:45
Thanks again, Simon! Sorry about the late reply. This is exactly what I wanted! –  user11781 Jan 23 '14 at 5:40

One way to approach this is to define a single function (here called f) that encapsulates all four of the portions of your curve.

f[j_, i_] := Table[{j (-1 + H^4)/(4 H^2), i Sqrt[1 - H^2 + (2 H^2 (-1 + H^4))/(4 H^2) -
H^2 ((-1 + H^4)/(4 H^2))^2]/H}, {H, 1, 1 + Sqrt[2], 0.01}];
Manipulate[Graphics[{Green, Circle[{1, 0}, 1/H], Blue, Circle[{-1, 0}, H],
Black, BezierCurve[f[1, 1]], BezierCurve[f[1, -1]],
BezierCurve[f[-1, 1]], BezierCurve[f[-1, -1]]}, Axes -> True],
{H, 1/(Sqrt[2] + 1), Sqrt[2] + 1}]

-
Thank you very much Mr. Bill! I'd rate you up, but I'm too new :(. –  user11781 Jan 16 '14 at 6:09