5. Suppose a bag contains one red, one yellow, and one blue ball. Each time a ball is drawn from the bag (the probability of drawing a ball of any color is the same), its color is determined and then it is put back. This process continues until two red balls are drawn consecutively, and let the number of draws at this point be $\xi$. Then the mathematical expectation of $\xi$ is $\qquad$
5.12.

Let the expected value we are looking for be $E$. The expected number of times the color of the first ball drawn is red, yellow, or blue is denoted as $\mathrm{E}(a) 、 \mathrm{E}(b) 、 \mathrm{E}(c)$. Then,
$$
\mathrm{E}(b)=\mathrm{E}(c) \text {. }
$$

Since the probability of the first ball drawn being red, yellow, or blue is the same, we have,
$$
E=\frac{\mathrm{E}(a)+2 \mathrm{E}(b)}{3} \text {. }
$$

First, consider the case where the first ball drawn is red. If the second ball drawn is also red, the operation ends; otherwise, if the first ball is red and the second ball is yellow or blue, ignoring the first ball, the remaining drawing methods can be considered as a new method (i.e., the first ball is yellow or blue), then
$$
\mathrm{E}(a)=\frac{1}{3} \times 2+\frac{2}{3}(1+\mathrm{E}(b)) \text {. }
$$

Next, consider the case where the first ball drawn is yellow or blue. Ignoring the first ball, the remaining drawing methods can be considered as a new method. Then,
$$
\mathrm{E}(b)=E+1 \text {. }
$$

From equations (1), (2), and (3), we solve to get $E=12$.