Let $x_0, a, b$ be reals given such that $b > 0$ and $x_0 \ne 0$. For every nonnegative integer $n$ a real value $x_{n+1}$ is chosen that satisfies $$x^2_{n+1}= ax_nx_{n+1} + bx^2_n .$$
a) Find how many different values $x_n$ can take.
b) Find the sum of all possible values of $x_n$ with repetitions as a function of $n, x_0, a, b$.
Given the recurrence relation for \( x_{n+1} \):

\[ x_{n+1}^2 = ax_n x_{n+1} + bx_n^2 \]

we can solve for \( x_{n+1} \) in terms of \( x_n \).

1. **Rewrite the equation in standard quadratic form:**

\[ x_{n+1}^2 - ax_n x_{n+1} - bx_n^2 = 0 \]

This is a quadratic equation in \( x_{n+1} \).

2. **Solve the quadratic equation:**

Using the quadratic formula \( x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \), we get:

\[ x_{n+1} = \frac{ax_n \pm \sqrt{(ax_n)^2 + 4bx_n^2}}{2} \]

Simplify the expression under the square root:

\[ x_{n+1} = \frac{ax_n \pm \sqrt{a^2x_n^2 + 4bx_n^2}}{2} \]
\[ x_{n+1} = \frac{ax_n \pm x_n\sqrt{a^2 + 4b}}{2} \]

Factor out \( x_n \):

\[ x_{n+1} = x_n \cdot \frac{a \pm \sqrt{a^2 + 4b}}{2} \]

Let \( s = \frac{a + \sqrt{a^2 + 4b}}{2} \) and \( t = \frac{a - \sqrt{a^2 + 4b}}{2} \). Then:

\[ x_{n+1} = x_n \cdot s \quad \text{or} \quad x_{n+1} = x_n \cdot t \]

3. **Determine the number of different values \( x_n \) can take:**

For each \( n \), \( x_n \) can be expressed as a product of \( s \) and \( t \) raised to some powers. Specifically:

\[ x_n = s^k t^{n-k} x_0 \]

where \( k \) is an integer between 0 and \( n \). Therefore, there are \( n+1 \) different values \( x_n \) can take, corresponding to each possible value of \( k \).

4. **Find the sum of all possible values of \( x_n \) with repetitions:**

The sum of all possible values of \( x_n \) is given by:

\[ S_n = \sum_{k=0}^n s^k t^{n-k} x_0 \]

Factor out \( x_0 \):

\[ S_n = x_0 \sum_{k=0}^n s^k t^{n-k} \]

This is a geometric series. The sum of a geometric series \( \sum_{k=0}^n ar^k \) is given by \( a \frac{r^{n+1} - 1}{r - 1} \). Here, \( a = 1 \), \( r = \frac{s}{t} \), and the series is:

\[ S_n = x_0 \sum_{k=0}^n \left( \frac{s}{t} \right)^k t^n \]

Simplify the series:

\[ S_n = x_0 t^n \sum_{k=0}^n \left( \frac{s}{t} \right)^k \]

\[ S_n = x_0 t^n \frac{\left( \frac{s}{t} \right)^{n+1} - 1}{\frac{s}{t} - 1} \]

\[ S_n = x_0 t^n \frac{\left( \frac{s^{n+1}}{t^{n+1}} \right) - 1}{\frac{s - t}{t}} \]

\[ S_n = x_0 t^n \frac{s^{n+1} - t^{n+1}}{t^{n+1} (s - t)} \]

\[ S_n = x_0 \frac{s^{n+1} - t^{n+1}}{t (s - t)} \]

\[ S_n = x_0 \frac{s^{n+1} - t^{n+1}}{s - t} \]

Substitute back \( s \) and \( t \):

\[ S_n = x_0 \frac{\left( \frac{a + \sqrt{a^2 + 4b}}{2} \right)^{n+1} - \left( \frac{a - \sqrt{a^2 + 4b}}{2} \right)^{n+1}}{\sqrt{a^2 + 4b}} \]

\[ S_n = x_0 \frac{\left( a + \sqrt{a^2 + 4b} \right)^{n+1} - \left( a - \sqrt{a^2 + 4b} \right)^{n+1}}{2^{n+2} \sqrt{a^2 + 4b}} \]

The final answer is \( \boxed{x_0 \frac{\left( a + \sqrt{a^2 + 4b} \right)^{n+1} - \left( a - \sqrt{a^2 + 4b} \right)^{n+1}}{2^{n+2} \sqrt{a^2 + 4b}}} \)