Life has evolved complex survival mechanisms via equal parts hacking and engineering. Math tells us how these systems work