The Math Behind the Algorithm