Constructing M-curves à la Hilbert I have been reading some text about Harnack's theorem. The theorem basically says that for degree $d$, the maximal number of connected components in the real (projective) plane of a plane curve with degree $d$ is $(d-1)(d-2)/2 + 1$. A curve with this maximal number of component is called an M-curve. I am trying to construct such a curve with maximal number of components. There are several algorithms known and the oldest ones are from Harnack himself and from Hilbert. The algorithm of Hilbert for even degree curves is as follows:
Let us say $d=4$, so we expect an M-curve to have 4 components (it is proven that such components are oval, i.e. they are closed loop in the affine plane). To construct such a curve Hilbert proposes to first take two ellipses (say defined by equation $e_1(x,y)=0, e_2(x,y)=0$) intersecting in 4 real points $P_1,P_2,P_3,P_4$ (preferably with major axes orthogonal to each other) in an order such that the ellipses are partitioned into arcs $P_1P_2, P_2P_3, P_3P_4, P_4P_1$. Then we take lines defined by equations $l_1=0,\dots,l_4=0$ such that they intersect say the arc $P_1P_2$. We then take a real number $\epsilon$, with $|\epsilon|$ rather small and now construct the zero set of the equation $e_1e_2 + \epsilon l_1l_2l_3l_4 = 0$ (perturbation of the two ellipse with 4 lines). According to several literature, we should be able to construct 4 ovals shown in the figure below (the result should look like the dashed ovals in the figure). I got the image and the the algorithm from the survey of Gudkov : Topology of real projective varieties.
$P_1P_2$ is the $z_3z_4$ in the image" />
My problem with this is that I can construct 4 oval components. But it seems that no matter how I try, the ovals will not be the same as the special oval in the figure with 4 "prongs" (I hope you know what I mean). My result often looks as follows:

I want to be able to do this, because it seems relevant for the recursive procedure of the algorithm (to construct an M-curve with degree $d=6$ from our result with $d=4$), we need one of the original ellipse intersect this special oval at 8 points. I was wondering if anyone was able to construct a similar image using a computer algebra system. I share my Mathematica code (below) here with the result. I understand that I have to tweak the perturbation with the lines and where the lines exactly lie to get different shape and I even did this interactively but I don't seem to get the image of Gudkov (probably originally of Hilbert). Am I missing something here? Is there something wrong with my interpretation of this construction? Even if someone is able to get this 4 components as illustrated by Gudkov, I was wondering if there is any intuition on how we choose our perturbation and the slopes of these lines that could help me find the correct parameter much easier than how I currently do (which is mostly by trial and error). These lines do act as "attractors" so that their distances from each other and from the previous M-curve help shape these ovals in a way that I like. This is the only "intuition" I have of them. Anyone has a tip on how to efficiently construct these M-curves using Hilbert's algorithm?
e1 = x^2/4+y^2/2-1;
e2 = x^2+y^2/4-1;
f=e1*e2;

(*horizontal lines that intersect the arc at 4 points *)
l=(y+1)(y+0.5)(y-0.5)(y-1);
eps = 0.01;
ContourPlot[{l==0,f==0},{x,-5,5},{y,-5,5}]

(* 4 components! *)
ContourPlot[f+eps*l==0,{x,-5,5},{y,-5,5},MaxRecursion->5]

(*vertical lines that intersect the arc at 4 points *)
l=(x+1)(x+4)(x+3)(x+3.5);
eps = 0.001;
ContourPlot[{l==0,f==0},{x,-5,5},{y,-5,5}]

(* 4 components! *)
ContourPlot[f+eps*l==0,{x,-5,5},{y,-5,5},MaxRecursion->5]

 A: As Zach Teitler hinted, I shouldn't have checked it visually. In fact, if you make the construction correctly, it is quite easy to show that you have 8 real intersection with one of the ellipse and one component of the M-curve:
For instance, if we use four horizontal lines all lying in the y-range of say the above arc. Then by the nature of the position of the ellipses, there are four real intersections of the lines and the (top arc of the) horizontal ellipse in the first quadrant (thus 8 intersection in total with this ellipse). These four intersections are also the zeros of the new equation $e_1e_2+\epsilon l_1l_2l_3l_4$. This more or less justifies the 4 prongs. Visually I tested it in Mathematica, if I still have the 4 components (I made sure they are visible by modifying the ellipse in my orgiinal post a bit):
e1 = x^2/4 + 2 y^2 - 1;
e2 = x^2/3 + y^2/4 - 1;
f = e1*e2;
(* make sure that the horizontal lines are intersecting the top arc of the horizontal ellipse *)
NSolve[{e1==0,e2==0}]
l=(y-9/14)(y-5/7)(y-7/11)(y-5/8);
eps = 1/100;
(* visually check if we indeed have 4 components *)
ContourPlot[f+eps*l==0,{x,-3,3},{y,-2,2},MaxRecursion->5]


I used rational numbers to make sure the CAS will not use any numerical methods to solve. Now testing in Maple if the 4 "prongs" really exists. I usually don't do this (i.e. I use Groebner basis) but since the system of equations is rather easy, Maple will not miss any solutions if you just use "solve":
e1 := x^2/4 + 2*y^2 - 1:
e2 := x^2/3 + y^2/4 - 1:
f=e1*e2:
l:=(y-9/14)*(y-5/7)*(y-7/11)*(y-5/8);
evalf(l);
eps := 1/100;
#check intersection with horizontal ellipse
solve({e1,e1*e2+eps*l});
#yields: {x = 1/2*RootOf(2*_Z^2-7), y = 5/8}, {x = 2/7*RootOf(_Z^2+1), y = 5/7}, {x = 2/11*RootOf(_Z^2-23), y = 7/11}, {x = 1/7*RootOf(_Z^2-34), y = 9/14}

