How closely is music related to mathematics?
Many people believe that there are similarities between mathematical and musical intelligence. Check out Howard Gardner's theory of multiple intelligences.
Personally, as a musician of almost twenty years, maths, particularly mental mathematics, has always been my weakness. I can't see how mathematics, which is an objective art & science, meaning that a calculation is either correct or incorrect.
In most popular western music genres you only really need to be able to count to multiples of four up to sixteen or thirty two to structure an arrangement for a song.
Whereas music is a subjective art & science, meaning that it is correct or incorrect based on the opinion of the audience or person listening.
On the other hand, I believe that there is a stronger correlation to mathematicians loving music because of the complicated mathematics, codes and sub divisions of pitches and rhythms. Check Albert Einstein.
Therefore, I think that the main similarity of both subjects is that there is an element of art and science within them.