CEMC Banner

Problem of the Week
Problem E and Solution
Mapping the Beats 3

Problem

Music streaming services often describe both songs and listeners using numerical characteristics called features. Artificial intelligence systems then use these features to predict what songs a listener is most likely to enjoy. One type of AI system is a neural network. In addition to music recommendation systems, neural networks are also used in image recognition and large language models (LLMs). Although real neural networks contain many hidden layers and millions of parameters, they are built on the same mathematical idea explored in this problem: information is transformed through a sequence of functions to produce a prediction.

Real recommendation systems often use many features at once. Songs and listeners can therefore be represented as points in a multi-dimensional coordinate system called a feature space. Recommendations for a listener can then be made by looking for songs represented by points that are close in distance to the point representing the listener’s preferences.

A particular music app represents songs and listeners using three scores: Energy, Danceability, and Happiness. These are expressed as points \((E,D,H)\) where \(E\), \(D\), and \(H\) are integers from \(1\) to \(10\). Suppose we have songs \(Q=(5,8,5)\), \(R=(8,5,2)\), \(S=(6,6,7)\), \(T=(3,9,3)\) and listener \(P=(6,7,4)\).

  1. Use the three-dimensional distance formula \(d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}\) to calculate the distance from \(P\) to each song. Which of the four songs would the streaming service recommend for this listener?

  2. Determine the number of points \((E,D,H)\) whose distance from \(P=(6,7,4)\) is at most \(3\).

Solution

  1. The distance from \(P\) to each song is shown. \[\begin{aligned} d_Q&=\sqrt{(5-6)^2+(8-7)^2+(5-4)^2}\\ &=\sqrt{1+1+1}\\ &=\sqrt{3}\approx 1.732 \end{aligned}\] \[\begin{aligned} d_R&=\sqrt{(8-6)^2+(5-7)^2+(2-4)^2}\\ &=\sqrt{4+4+4}\\ &=\sqrt{12}\approx 3.464 \end{aligned}\] \[\begin{aligned} d_S&=\sqrt{(6-6)^2+(6-7)^2+(7-4)^2}\\ &=\sqrt{0+1+9}\\ &=\sqrt{10}\approx 3.162 \end{aligned}\] \[\begin{aligned} d_T&=\sqrt{(3-6)^2+(9-7)^2+(3-4)^2}\\ &=\sqrt{9+4+1}\\ &=\sqrt{14}\approx 3.741 \end{aligned}\]

    Since the distance is the smallest from \(P\) to song \(Q\), the streaming service would recommend song \(Q\) to the listener.

  2. If the distance between \(P=(6,7,4)\) and \((E,D,H)\) is at most \(3\), then \[\begin{aligned} \sqrt{(E-6)^2+(D-7)^2+(H-4)^2}& \le 3\\ (E-6)^2+(D-7)^2+(H-4)^2&\le 9 \end{aligned}\] Since \(E\), \(D\), and \(H\) are integers, then \((E-6)^2\), \((D-7)^2\), and \((H-4)^2\) must each be perfect squares. Since their sum is at most \(9\), the possibilities are \(0+0+0\), \(1+0+0\), \(4+0+0\), \(9+0+0\), \(1+1+0\), \(4+1+0\), \(4+4+0\), \(1+1+1\), \(4+1+1\), or \(4+4+1\). Note that the maximum value is \(9\), and \((E-6)^2\), \((D-7)^2\), and \((H-4)^2\) can each equal \(9\) when \(E\), \(D\), and \(H\) are integers from \(1\) to \(10\). We determine the possible points \((E,D,H)\) by looking at the number of zeros in \((E-6)^2\), \((D-7)^2\), and \((H-4)^2\).

    Therefore, there are a total of \(1+18+24+24+8+48=123\) points whose distance from \(P\) is at most \(3\).

Note: To calculate this answer, we could also look at a sphere of radius \(3\), centred at \((6,7,4)\). The points \((E,D, H)\) that we are looking for correspond to the points inside this sphere with integer coordinates between \(1\) and \(10\).