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]