Mathematics of Magic Angles