The Miami Heat and the San Antonio Spurs are playing a best-of-five series basketball championship, in which the team that first wins three games wins the whole series. Assume that the probability that the Heat wins a given game is $x$ (there are no ties).  The expected value for the total number of games played can be written as $f(x)$, with $f$ a polynomial.  Find $f(-1)$.
1. **Determine the probabilities for the series lasting 3, 4, and 5 games:**

   - The probability that the series lasts exactly 3 games:
     \[
     P(\text{3 games}) = x^3 + (1-x)^3
     \]
     This is because either the Heat wins all three games, or the Spurs win all three games.

   - The probability that the series lasts exactly 4 games:
     \[
     P(\text{4 games}) = 3x^3(1-x) + 3(1-x)^3x
     \]
     This is because one team wins three games, and the other team wins exactly one game. The factor of 3 accounts for the different positions the single win can occur in the sequence of four games.

   - The probability that the series lasts exactly 5 games:
     \[
     P(\text{5 games}) = 6x^2(1-x)^2
     \]
     This is because the first four games must be split 2-2, and then the fifth game determines the winner. The factor of 6 accounts for the different ways to arrange two wins for each team in the first four games.

2. **Calculate the expected number of games:**

   The expected number of games, \(E\), is given by:
   \[
   E = 3 \cdot P(\text{3 games}) + 4 \cdot P(\text{4 games}) + 5 \cdot P(\text{5 games})
   \]

   Substituting the probabilities:
   \[
   E = 3 \left( x^3 + (1-x)^3 \right) + 4 \left( 3x^3(1-x) + 3(1-x)^3x \right) + 5 \left( 6x^2(1-x)^2 \right)
   \]

3. **Simplify the expression:**

   \[
   E = 3 \left( x^3 + (1-x)^3 \right) + 12 \left( x^3(1-x) + (1-x)^3x \right) + 30x^2(1-x)^2
   \]

   \[
   E = 3x^3 + 3(1-x)^3 + 12x^3(1-x) + 12(1-x)^3x + 30x^2(1-x)^2
   \]

4. **Evaluate \(f(-1)\):**

   Substitute \(x = -1\) into the polynomial \(f(x)\):
   \[
   f(-1) = 3(-1)^3 + 3(1-(-1))^3 + 12(-1)^3(1-(-1)) + 12(1-(-1))^3(-1) + 30(-1)^2(1-(-1))^2
   \]

   Simplify each term:
   \[
   f(-1) = 3(-1) + 3(2)^3 + 12(-1)(2) + 12(2)^3(-1) + 30(1)(2)^2
   \]

   \[
   f(-1) = -3 + 3 \cdot 8 + 12(-2) + 12 \cdot 8(-1) + 30 \cdot 4
   \]

   \[
   f(-1) = -3 + 24 - 24 - 96 + 120
   \]

   \[
   f(-1) = -3 + 24 - 24 - 96 + 120 = 21
   \]

The final answer is \(\boxed{21}\).