This is a follow-up to this question:The OP asks how to compute the genus (or Euler characteristic) of a parametrized surface in $\mathbb{R}^3.$ One of the commenters recommends the Gauss-Bonnet formula, which I pooh-poohed in my answer, but then thought that I should try it before heaping scorn. Luckily, the code to compute Gauss curvature is given in another MSE post. and implementing this, one gets the following formula for the Gauss curvature of the torus given by
ParametricPlot3D[
{Cos[x] + .4 Cos[x] Sin[y], Sin[x] + .4 Sin[x] Sin[y], Cos[y]},
{ x, 0, 2 π}, {y, 0, 2 π}]
(this was one of the examples in the first referenced question).
Sure enough, I got:
(-0.260682 + 0.264024 Cos[2 y] - 0.00334208 Cos[4 y] -
0.568153 Sin[y] + 0.0501312 Sin[3 y])/(-0.78609 + 1. Cos[2 y] -
0.264011 Cos[4 y] + 0.0235115 Cos[6 y] - 0.000147386 Cos[8 y] -
1.26981 Sin[y] + 0.56683 Sin[3 y] - 0.0988186 Sin[5 y] +
0.00294771 Sin[7 y])
which seems reasonable, but then NIntegrating it over the parameter space $[0, 2 \pi] \times [0, 2 \pi]$ gives $-8.59435,$ which, whatever else it might be, is not zero. It is however, $-27/\pi.$ Would anyone care to explain what the heck is going on?