1. do the math - Verb
2. do the math - Phrase
(chiefly US) To perform a mathematical calculation.
(chiefly US, idiomatic) To determine the explanation for or precise nature of a situation, such as the motive underlying someone's behavior, based on available facts.
Source: en.wiktionary.org