The math of how a cat works