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)\).
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?
Determine the number of points \((E,D,H)\) whose distance from \(P=(6,7,4)\) is at most \(3\).
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.
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\).
Case 1: All three of \((E-6)^2\), \((D-7)^2\), and \((H-4)^2\) are \(0\).
Then the only possible value of \((E,D,H)\) is \((6,7,4)\). Thus, there is \(1\) point.
Case 2: Two of \((E-6)^2\), \((D-7)^2\), and \((H-4)^2\) are \(0\).
Then there are \(3\) possibilities for
the value of the other expression (\(1\), \(4\), or \(9\)). There are then \(3\) ways to assign the values to the
expressions. For the nonzero expression, there are \(2\) possible values for that feature, since
the difference can be either positive or negative. However, for the
expressions that equal \(0\) there is
only one possible value for those features. This gives \(3 \times 3 \times 2 =18\) points in
total.
Case 3: One of \((E-6)^2\), \((D-7)^2\), and \((H-4)^2\) is \(0\).
If the other expressions are equal, then there are \(2\) possibilities (\(1\) and \(1\), or \(4\) and \(4\)). For each of these possibilities, there are \(3\) ways to assign the values to the expressions. For the nonzero expressions, there are \(2\) possible values for each of those features, since the difference can be either positive or negative. However, for the expression that equals \(0\) there is only one possible value for that feature. This gives \(2 \times 3 \times 2 \times 2 =24\) points in total.
If the other expressions are not equal, then the only possibility is \(4\) and \(1\). Then there are \(6\) ways to assign the values to the expressions. For the nonzero expressions, there are \(2\) possible values for each of those features, since the difference can be either positive or negative. However, for the expression that equals \(0\) there is only one possible value for that feature. This gives \(6 \times 2 \times 2 =24\) points in total.
Case 4: None of \((E-6)^2\), \((D-7)^2\), and \((H-4)^2\) is \(0\).
If the three expressions are equal, then the only possibility is \(1\), \(1\), and \(1\). There is then only one way to assign the values to the expressions. For each expression, there are \(2\) possible values for the feature, since the difference can be either positive or negative. This gives \(2 \times 2 \times 2 =8\) points in total.
If the three expressions are not equal, then there are \(2\) possibilities (\(4\), \(1\), and \(1\), or \(4\), \(4\), and \(1\)). For each of these, there are \(3\) ways to assign the values to the expressions. For each expression, there are \(2\) possible values for the feature, since the difference can be either positive or negative. This gives \(2 \times 3 \times 2 \times 2 \times 2 =48\) points in total.
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\).