I am learning differential geometry by programming them and seeing their shapes. But topology is absolutely mysterious to me. For example, a sphere $$ x^2+y^2+z^2=r^2 $$ has genus 0 (no holes).
and a torus $$ \left(R- \sqrt{x^2+y^2} \right)^2+z^2=r^2 $$ has genus 1 (with one hole).
But is there a formula than can actually derive the number 0, and 1 from the above equations? In other words, how to compute the genus of an algebraic surface?
p.s. Most functions I know return a real number (e.g. $\sin$, $\cos$, $\exp$, etc), so I am very curious about how a function transform a surface representation into an integer. Or, Does "a surface has genus 1.5 " make any sense?
Any compact Riemann surface $R$ is homeomorphic to a sphere with handles. The number $g$ of handles is called the genus of $R$. With this standard definition we see that the first example, the sphere without handles, has genus zero, whereas the torus can be deformed (the hole becomes a handle) to a sphere with $1$ handle. Hence its genus is equal to $1$. There are also several other methods to compute the genus $g$ of a compact Riemannian manifold, e.g., $g=(\chi(R)-2)/2$, where $\chi(R)$ is the Euler characteristic. See also for "Riemann-Hurwitz formula", or "Riemann-Roch".