SetOptions[EvaluationNotebook[],CellContext->Notebook]

ttorus[a_:2,b_:1,c_:1][u_,v_]:={(a+b Cos[v])Cos[u],(a+b Cos[v])Sin[u],c Sin[v]}

Introducing Topology with Mathematica

Andrzej Kozłowski

Mathematica Day Warsaw University 2017

Consider the following polynomial equation

-8+16 (x^2)+16 (y^4)-32 (y^2) (z^2)+16 (z^4)+8 (y^2) (z^4)-8 (z^6)+(z^8)=0

The set of points (x,y,z) satisfying this equation represents some surface (called a hyper-surface) in (ℝ^3).  What can we say about this surface without using a 3D graphing program (we will use one later)? We will see that we can determine exactly the topology of this spaces.

Topological space: set with a family of open (and hence closed) subsets.  Makes it possible to define continuous maps. Inverse image of an open (closed) set by a continuous map is open (closed). Continuous functions are continuous maps into ℝ (which has the usual topology induced by the Euclidean metric).

A manifold (without a boundary)  is a topological space in which each point has a neighborhood homeomorphic to an open subset of (ℝ^d) in a  way consistent on the intersections. A collection of such open sets is called an atlas and the functions from (ℝ^d) to (ℝ^d) defined by intersections of open sets in the atlas are called transition functions (required to be continuous). 
The integer d is called the dimension of a manifold.

Manipulate[Show[ParametricPlot3D[Evaluate[ttorus[2,1,1][u,v]],{u,0,2Pi},{v,0,2Pi},ColorFunction->({Opacity[0.5],Green}&),Mesh->False,Ticks->False,RegionFunction ->If[full,Function[{x,y,z},Norm[{x,y,z}-ttorus[2,1,1]@@p]<1/2],True&]],Graphics3D[{ Red,PointSize[0.01],Point[ttorus[2,1,1]@@p]}],PlotRange->{{-3,3},{-3,3},{-3,3}}],{{p,{0,0}},{-Pi,-Pi},{Pi,Pi},Slider2D},{{full,False,"show Euclidean neighbourhood"},{True,False}},SaveDefinitions->True]

Without loss of generality once can always assume that a manifold (of dimension d) is a subspace of (ℝ^n) for some n>d. There are also manifolds with a boundary: in that case each point has a neighborhood homeomorphic to {((Subscript[x, 1]),…,(Subscript[x, n])),(Subscript[x, n])≥0}.

GraphicsGrid[{{Graphics[{Blue,Disk[{0,0},1]}],Graphics[{Blue, Circle[{0,0},1]}]}}]

Differentiable structure

A differentiable manifold is a topological manifold with an atlas with differentiable transition functions.

GraphicsGrid[{{Graphics3D[{Blue,Sphere[{0,0,0},1]},Boxed->False],Graphics3D[{Blue, Cuboid[]},Boxed->False]}}]

Homeomorphism and diffeomorphism. Classification.

The main (but unachievable) aim of topology is classification of manifolds up to homeomorphism (diffeomorphism).

Manipulate[ParametricPlot3D[ttorus[a,b,c][u,v],{u,0,2Pi},{v,0,2Pi},Mesh->False,Ticks->False],{{a,1,"a"},0.1,5},{{b,1,"b"},0.1,5},{{c,1,"c"},0.1,5}]

Homotopy,

Classifying topological spaces, or even manifolds up to homeomorphism is usually an extremely difficult and in general impossible task.  Because of this, topologists often settle for something less ambitious. One approach is to replace classification up to homeomorphism with one up to homotopy equivalence. Two spaces are homotopy equivalent if one them can be continuously deformed onto the other. For example the disk (but not the circle!) is homotopy equivalent to a point (contractible). Of course the point cannot be continuously deformed into the ball, and neither can a sphere be deformed into a point .

Manipulate[Graphics[{Opacity[0.5],Red, Disk[{0,0},r],Blue,Point[{0,0}]},PlotRange->{{-1,1},{-1,1}},ImageSize->Small],{r,1,0.01},SaveDefinitions->True]

Manipulate[Graphics[{Opacity[0.5],Red, Circle[{0,0},r],Blue,Point[{0,0}]},PlotRange->{{-1,1},{-1,1}},ImageSize->Small],{r,1,0.01},SaveDefinitions->True]

Manipulate[Graphics[{Red, Circle[{0,0},1],Line[{{1/Sqrt[2],1/Sqrt[2]},{t,t}}]},PlotRange->{{-2,2},{-2,2}}],{t,1/Sqrt[2]+1,1/Sqrt[2]},SaveDefinitions->True]

Homology and  the Euler Characteristics.

This is a sphere made up of by regular polygons. It is in fact, homeomorphic to the original sphere. Such a manifold can be divided into polyhedra in lots of way. However, there are "invariants" that can be computed from this polyhedral decompositions, such as homology and cohomology groups. They are "invariants" in the sense that they depend only on the homotopy class of the manifold, not on the particular  polyhedral structure. The simplest and the most famous such invariant is the Euler characteristics: which is defined as the number of all the vertices plus the number of all the edges - the number of all the faces. This number does not depend on the decomposition and will be the same for homotopy equivalent manifolds.

ParametricPlot3D[{Cos[u]Cos[v],Cos[v]Sin[u],Sin[v]},{u,0,2Pi},{v,-Pi/2,Pi/2},PlotRange->All,Ticks->False]

A very special feature of surfaces is that for 2-manifolds the classifications up to diffeomorphism, homeomorphisms, homotopy, homology coincide. More precisely, all 2-manifolds are  of two kinds: orientable and non-orientable. Non-orientable compact surfaces I will leave for later. We will note know that they cannot be embedded in (ℝ^3) without self-intersections. We will concentrate now on compact orientable surfaces.

It turns out that, up to homeomorphism,  all (compact, closed) orientable surfaces  can all be constructed as follows.

We start with a sphere and slice off two disks from it, as follows:

g1=ContourPlot3D[(x^2)+(y^2)+(z^2)==1,{x,-1,1},{y,-1,1},{z,-1,1},ColorFunction->({Opacity[1],Green}&),RegionFunction->(#1^2+#2^2>1/16&),AxesLabel->{"x","y","z"},Ticks->False,Mesh->False,Boxed->False,Axes->False];

g2=Graphics3D[{Green,Cylinder[{{0,0,-1},{0,0,1}},1/8]},Boxed->False];

GraphicsGrid[{{g1,g2}}]

Manipulate[Show[ParametricPlot3D[Evaluate[RotationTransform[ϕ,{0,1,0},{2,2,0}][{Cos[θ]/4,Sin[θ]/4,Sqrt[15]/4}]],{θ,0,2Pi},{ϕ,Pi/300,b},Mesh->False,Ticks->False,AxesLabel->{"x","y","z"},ColorFunction->({Opacity[1],Green}&)],g1,Graphics3D[{Red,PointSize[0.02]}],PlotRange->All,Boxed->False,Axes->False],{{b,Pi/12,"β"},Pi/12,2Pi-Pi/5.3},SaveDefinitions->True]

Connected Sum

The alternative approach is via connected sum.

This is called attaching a handle (in this case a 2 handle) (or "surgery" ).  The space which we obtain has one hole and is called a torus (up to homotopy).

It turns out that every compact, orientable surface is homeomorphic (and if it is smooth, diffeomorphic) to a sphere with g 2-handles attached. It is usually represented like this

ParametricPlot3D[{(4+Cos[θ]) Sin[ϕ],Sin[θ],(4+Cos[θ]) Cos[ϕ]},{θ,-Pi,Pi},{ϕ,-Pi,Pi},ColorFunction->(Hue[#3]&),Mesh->False,Axes->False]

So any compact, orientable closed surface is a sphere with g handles attached or a torus with g-1 handles. The number of handles (or holes) g is called the genus of the surface and the Euler characteristic is 2-2g.  So if we know the genus or the Euler characteristic of a closed orientable we know all about its topology and even about its differentiable structure. None of it is not true in general, which is why the classification problem is so hard. However, we will now describe an approach which  works in any number of dimensions and, in principle, could determine the "diffeomorphism type" of a differentiable manifold.

The torus

A torus in  (ℝ^3) can also be obtained by rotating a circle about an axis in the plane of the circle which does not cross the circle. First we define a function which maps a circle into (ℝ^3).

circle[θ_]:={0,Sin[θ],Cos[θ]+4}

We can picture this circle in relation to the coordinates by using the function ParametricPlot3D:

ParametricPlot3D[circle[t],{t,-π,π},ColorFunction->(Red&),AxesLabel->{"x","y","z"},ImageSize->Small,Ticks->False]

We now define a function tor  that rotates a point on the above circle with parameter θ about the y-axis through an angle ϕ. We use Mathematica's built-in RotationTransform function:

tor[θ_,ϕ_]:=RotationTransform[ϕ,{0,1,0}][circle[θ]]

We will be frequently drawing a torus so we define a function that will do it with various specified parameters and options. First we define some options for our function.

tor[θ,ϕ]

Options[torus]=Options[ParametricPlot3D];

Now we define a function to draw a torus:

torus[a_:-π,b_:π,c_:-π,d_:π,OptionsPattern[]]:=ParametricPlot3D[tor[θ,ϕ],{ϕ,c,d},{θ,a,b},RegionFunction->OptionValue[RegionFunction],ColorFunction->OptionValue[ColorFunction],Mesh->OptionValue[Mesh],Axes->OptionValue[Axes],Boxed->OptionValue[Boxed],ImageSize->OptionValue[ImageSize],Evaluated->True,PlotRange->{{-5,5},{-5,5},{-5,5}},Ticks->False]

The next animation shows how the torus can be obtained by rotating a circle, but it can also be viewed as showing how a

height[θ_,ϕ_]=tor[θ,ϕ][[3]]

Brief Survey of Morse Theory

Manipulate[Show[torus[-Pi,Pi,-Pi,Pi,RegionFunction->(If[tt,True,(#3<t)]&)],If[ss,Plot3D[t,{x,-5,5},{y,-5,5},ColorFunction->({Opacity[0.3],Blue}&),Mesh->None],Graphics3D[{}]],PlotRange->{{-5,5},{-5,5},{-5,5}}],{{t,-5,"height"},-5,5,Appearance->"Labeled"},{{tt,False,"Show full turus"},{True,False}},{{ss,False,"Show plane"},{True,False}},Bookmarks->{"first":>(t=-5+0.01),"second":>(t=-3+0.001),"third":>(t=3+0.001),"fourth":>(t=5)},SynchronousUpdating->True,ContinuousAction->True,SaveDefinitions->True]

Critical Points

The critical points of a function are the points where the gradient takes the value 0, in other words, where all the partial derivatives vanish. It is easy to show that the notion of critical point is independent of the local coordinate system.  Mathematica has a built-in function Gradient (which in StandardForm and TraditionalForm looks like the usual mathematical symbols for this operation)

(Grad[f[x,y], {x,y}])==0

Next we look for all critical points of the height function on the torus. We can use the Solve or the Reduce functions. Solve has the advantage that it gives its answer in the form of rules, which is often convenient, but Reduce can solve a greater variety of equations (and inequalities). One way to get both advantages is to use Solve with the option: Method->Reduce

solrules=Solve[(Grad[height[θ,ϕ], {θ,ϕ}])==0&&-π<θ≤π&&-π<ϕ≤π,{θ,ϕ},Method->Reduce]

We would like to sort the solutions according to the height (from lowest to highest), so we use the Sort command with a suitable sorting function as the second argument.

solrules=Sort[solrules,(height[θ,ϕ]/. #1)<(height[θ,ϕ]/. #2)&];

The coordinates of the critical points are

sols={θ,ϕ}/. solrules

Now let's calculate the heights at the critical points (the critical values of the height function ).

heights=Apply[height,sols,{1}]

Finally, we look at some pictures of the torus and the critical points.

criticalpoints=Graphics3D[({Red,PointSize[0.02],Point[#1]}&)/@(tor[θ,ϕ]/. solrules),Boxed->False];

Show[{torus[-π,π,-π,π,Mesh->None,ColorFunction->(Directive[Opacity[0.2],Green]&)]},criticalpoints,Boxed->True,PlotRange->All,Axes->False,ImageSize->Small]

The Hessian, The Morse Lemma, and the Index of a critical point.

If  P is a critical point of  f,  the we define the Hessian of f at P as the symmetric bilinear form on the tangent space at P, which in a local coordinate system can be represented as the matrix of second derivatives

(({{(((∂^2)f)/(∂(Subscript[x, i]) ∂(Subscript[x, j])))}})(P))

This definition (the matrix ) depends on the choice of coordinates at P, but the corresponding symmetric bilinear form (on the tangent space) and its determinant  is independent of the choice of local coordinates. In Mathematica  we can define the Hessian as:

hessian[f_,vars_List]:=(∂_({vars,2}))f

We say that a critical point is non-degenerate if the determinant of the Hessian matrix is non-zero. One can show that all non-degenerate critical points are isolated.

We now compute the Hessian  matrices at all our critical points:

MatrixForm/@(hessians=hessian[height[θ,ϕ],{θ,ϕ}]/. solrules)

A critical point is said to be non-degenerate if its Hessian has maximal rank, i.e. its null space is zero. Again, this is easy to check with Mathematica:

Map[NullSpace,hessians]

A function all of whose critical points are isolated and non-degenerate is called a Morse function. So the height function given by the z coordinate is indeed a Morse function.

The index of a non-degenerate critical point is defined as the number of negative eigenvalues of the Hessian. It can be defined in Mathematica  as follows.

index[f_,x_List,a_List]:=Count[Eigenvalues[hessian[f,x]/. Thread[x->a]],_?Negative]

Here are the indices of our four critical points.

indices=(index[height[x,y],{x,y},#1]&)/@sols

When studying the topology of a manifold by means of a Morse function, it is often useful to consider the Morse Polynomial, which is a polynomial in a variable t, whose (t^i) coefficient is the number of critical points of index i. The Mathematica definition is:

MorsePolynomial[indices_List,t_]:=(∑_(i=Min[indices])^(Max[indices]))Count[indices,i] (t^i)

For our torus we have:

MorsePolynomial[indices,t]

EC[indices_]:=MorsePolynomial[indices,-1]

In the case of the torus

EC[indices]

This is a special case of the Hopf Index Theorem, which holds for any smooth vector field (not just the gradient vector field that will be considered below).

Implicitization and Real Algebraic Geometry

Above we made use of parametric representation of the torus to obtain local coordinates which allowed us to compute the coordinates of singular points and their indexes.  Many important surfaces which appear in geometry, topology and applications are not given in terms of parametric representation (or local coordinate patches) but as the set of zeros of some smooth function. If the function is a polynomial, the surface is called an algebraic surface. By the implicit function theorem, if the points of this zero set are non-singular (the Jacobian matrix has maximal rank), the set of zeros will be a smooth manifold.  This means that it is always possible to choose a local coordinate system and perform similar computations to those above. However, it is often convenient to do the computations without choosing coordinates, purely in terms of the system of equations defining the manifold. When the equations are algebraic, the set of solutions is called an algebraic set or a variety.

An algebraic subset of (ℝ^n) is the set of common solutions of a finite set of polynomials  {(Subscript[f, 1]),(Subscript[f, 2]),…,(Subscript[f, m])}(or the ideal generated by these). Such a set is said to be non-singular if the Jacobian matrix (({{((∂(Subscript[f, i]))/(∂(Subscript[x, j])))}})) has rank n-m.

The flowing theorem tells us that  the class of non-singular algebraic surfaces includes all smooth manifolds, up to diffeomorphism.

Tognoli's Theorem
Let M⊂ (ℝ^n) be a compact (C^∞)submanifold. Then M is diffeomorphic to a non-singular algebraic subset of (ℝ^(n+1)).

It is not known whether n+1 can be in general replaced by n. However it is known that we can represent all closed orientable surfaces by non-singular algebraic sets in (ℝ^3).

Theorem

Let W⊂ (ℝ^n) be a compact non-singular algebraic hypersurface defined by the equation f=0, where f is a polynomial. Then (possibly after a change of coordinates) one can find a height function h which is a Morse function whose critical points are the solutions of n-polynomial equations: f=0,((∂f)/(∂(Subscript[x, 1])))=0,…,((∂f)/(∂(Subscript[x, n-1])))=0. Moreover, the Hessian of the height function is -((H(f))/((∂f)/(∂(Subscript[x, n])))),where H(f) is the (n-1) × (n-1) matrix ((((∂^2)f)/(∂(Subscript[x, i])∂(Subscript[x, j])))).

Note than unlike in the complex case, the condition of being a hypersurface is not a restriction at all, since any real algebraic set is a real hypersurface. However, the requirement of being a non-singular hypersurface is, of course, a genuine restriction.

Mysterious surface

This method is particularly useful in situations when we do not know any parametric description of our surface. Consider the real algebraic hypersurface defined by the following equation.

myst[x_,y_,z_]:=-8+16 (x^2)+16 (y^4)-32 (y^2) (z^2)+16 (z^4)+8 (y^2) (z^4)-8 (z^6)+(z^8)

Let's verify that the surface is compact.

Maximize[{Abs[x],-8+16 (x^2)+16 (y^4)-32 (y^2) (z^2)+16 (z^4)+8 (y^2) (z^4)-8 (z^6)+(z^8)==0},{x,y,z}]

Maximize[{Abs[y],-8+16 (x^2)+16 (y^4)-32 (y^2) (z^2)+16 (z^4)+8 (y^2) (z^4)-8 (z^6)+(z^8)==0},{x,y,z}]//N

Maximize[{Abs[z],-8+16 (x^2)+16 (y^4)-32 (y^2) (z^2)+16 (z^4)+8 (y^2) (z^4)-8 (z^6)+(z^8)==0},{x,y,z}]//N

Let's first verify that the surface is non-singular.

singularPoints1=Solve[Join@@{(Grad[myst[x,y,z], {x,y,z}]),{myst[x,y,z]}}==0,{x,y,z},Reals,Method->Reduce]

Mathematica gives this answer when it is sure that the system of equations has no solutions, so (barring bugs in Mathematica's code) this proves that there are no singular points. Now we can use the above theorem to find the critical points. Since the exact solutions looks very complicated we will only display their numerical  approximations:

criticalPoints1=N[{x,y,z}/. Solve[Join@@{(Grad[myst[x,y,z], {x,y}]),{myst[x,y,z]}}==0,{x,y,z},Reals,Method->Reduce]]

We can compute the hessian matrices at the critical points.

hess2=-((hessian[myst[x,y,z],{x,y}])/((∂_z)myst[x,y,z]))

MatrixForm/@(hessians2=hess2/. Thread/@Apply[Rule,Flatten[Outer[List,{{x,y,z}},criticalPoints1,1],1],{1}])

Now we can count the positive and negative eigenvalues and compute the indices:

indices2=(Count[Eigenvalues[#1],_?Negative]&)/@Reverse[hessians2]

Finally we compute the Morse polynomial and the Euler characteristic:

MorsePolynomial[indices2,t]

EC[indices2]

So the Euler characteristic is -2. Let's check what our surface looks like with the help of CountourPlot3D

crits1={Red,PointSize[0.01],(Point[#1]&)/@criticalPoints1};

dt=ContourPlot3D[myst[x,y,z],{x,-6,6},{y,-2,2},{z,-6,6},Contours->{0},Mesh->False,ColorFunction->(Directive[Opacity[0.4],Green]&),Axes->False,Boxed->False,BoxRatios->{1,0.2,1},Evaluated->True,PerformanceGoal->Quality,PlotPoints->120];

Show[dt,Graphics3D[crits1],ImageSize->Large]

It turns out that our surface is a "double torus", which has genus 2 (where genus is "the number of holes"). It is known that the Euler characteristic of an orientable surface is 2-2g, where g is the genus, which shows that in our case it is indeed -2.

Non-orientable surfaces

cartesianKlein[x_,y_,z_]:=768 (x^4)-1024 (x^5)-128 (x^6)+512 (x^7)-80 (x^8)-64 (x^9)+16 (x^10)+144 (x^2) (y^2)-768 (x^3) (y^2)-136 (x^4) (y^2)+896 (x^5) (y^2)-183 (x^6) (y^2)-176 (x^7) (y^2)+52 (x^8) (y^2)+400 (y^4)+256 x (y^4)-912 (x^2) (y^4)+256 (x^3) (y^4)+315 (x^4) (y^4)-144 (x^5) (y^4)-16 (x^6) (y^4)+4 (x^8) (y^4)-904 (y^6)-128 x (y^6)+859 (x^2) (y^6)-16 (x^3) (y^6)-200 (x^4) (y^6)+16 (x^6) (y^6)+441 (y^8)+16 x (y^8)-224 (x^2) (y^8)+24 (x^4) (y^8)-76 (y^10)+16 (x^2) (y^10)+4 (y^12)-2784 (x^3) y z+4112 (x^4) y z-968 (x^5) y z-836 (x^6) y z+416 (x^7) y z-48 (x^8) y z+1312 x (y^3) z+2976 (x^2) (y^3) z-5008 (x^3) (y^3) z-12 (x^4) (y^3) z+2016 (x^5) (y^3) z-616 (x^6) (y^3) z-64 (x^7) (y^3) z+32 (x^8) (y^3) z-1136 (y^5) z-4040 x (y^5) z+2484 (x^2) (y^5) z+2784 (x^3) (y^5) z-1560 (x^4) (y^5) z-192 (x^5) (y^5) z+128 (x^6) (y^5) z+1660 (y^7) z+1184 x (y^7) z-1464 (x^2) (y^7) z-192 (x^3) (y^7) z+192 (x^4) (y^7) z-472 (y^9) z-64 x (y^9) z+128 (x^2) (y^9) z+32 (y^11) z-752 (x^4) (z^2)+1808 (x^5) (z^2)-1468 (x^6) (z^2)+512 (x^7) (z^2)-64 (x^8) (z^2)+6280 (x^2) (y^2) (z^2)-5728 (x^3) (y^2) (z^2)-4066 (x^4) (y^2) (z^2)+5088 (x^5) (y^2) (z^2)-820 (x^6) (y^2) (z^2)-384 (x^7) (y^2) (z^2)+96 (x^8) (y^2) (z^2)-136 (y^4) (z^2)-7536 x (y^4) (z^2)+112 (x^2) (y^4) (z^2)+8640 (x^3) (y^4) (z^2)-2652 (x^4) (y^4) (z^2)-1152 (x^5) (y^4) (z^2)+400 (x^6) (y^4) (z^2)+2710 (y^6) (z^2)+4064 x (y^6) (z^2)-3100 (x^2) (y^6) (z^2)-1152 (x^3) (y^6) (z^2)+624 (x^4) (y^6) (z^2)-1204 (y^8) (z^2)-384 x (y^8) (z^2)+432 (x^2) (y^8) (z^2)+112 (y^10) (z^2)+3896 (x^3) y (z^3)-7108 (x^4) y (z^3)+3072 (x^5) y (z^3)+768 (x^6) y (z^3)-768 (x^7) y (z^3)+128 (x^8) y (z^3)-3272 x (y^3) (z^3)-4936 (x^2) (y^3) (z^3)+8704 (x^3) (y^3) (z^3)-80 (x^4) (y^3) (z^3)-2496 (x^5) (y^3) (z^3)+608 (x^6) (y^3) (z^3)+2172 (y^5) (z^3)+5632 x (y^5) (z^3)-2464 (x^2) (y^5) (z^3)-2688 (x^3) (y^5) (z^3)+1056 (x^4) (y^5) (z^3)-1616 (y^7) (z^3)-960 x (y^7) (z^3)+800 (x^2) (y^7) (z^3)+224 (y^9) (z^3)+752 (x^4) (z^4)-1792 (x^5) (z^4)+1472 (x^6) (z^4)-512 (x^7) (z^4)+64 (x^8) (z^4)-3031 (x^2) (y^2) (z^4)+1936 (x^3) (y^2) (z^4)+2700 (x^4) (y^2) (z^4)-2304 (x^5) (y^2) (z^4)+448 (x^6) (y^2) (z^4)+697 (y^4) (z^4)+3728 x (y^4) (z^4)+24 (x^2) (y^4) (z^4)-3072 (x^3) (y^4) (z^4)+984 (x^4) (y^4) (z^4)-1204 (y^6) (z^4)-1280 x (y^6) (z^4)+880 (x^2) (y^6) (z^4)+280 (y^8) (z^4)-800 (x^3) y (z^5)+1488 (x^4) y (z^5)-768 (x^5) y (z^5)+128 (x^6) y (z^5)+992 x (y^3) (z^5)+1016 (x^2) (y^3) (z^5)-1728 (x^3) (y^3) (z^5)+480 (x^4) (y^3) (z^5)-472 (y^5) (z^5)-960 x (y^5) (z^5)+576 (x^2) (y^5) (z^5)+224 (y^7) (z^5)+16 (x^4) (z^6)+388 (x^2) (y^2) (z^6)-384 (x^3) (y^2) (z^6)+96 (x^4) (y^2) (z^6)-76 (y^4) (z^6)-384 x (y^4) (z^6)+208 (x^2) (y^4) (z^6)+112 (y^6) (z^6)-64 x (y^3) (z^7)+32 (x^2) (y^3) (z^7)+32 (y^5) (z^7)+4 (y^4) (z^8)

ContourPlot3D[cartesianKlein[x,y,z]==0,{x,-4,4},{y,-4,4},{z,-3.5,3.5},Mesh->False,Boxed->False,Axes->False,PerformanceGoal->"Quality"]