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?