Expanding a potential function via the generating function for Legendre polynomials The Generating function for Legendre Polynomials is:
$$\Phi(x,h)=(1-2xh+h^2)^{-1/2} \quad\text{for}\quad |h|\lt 1\tag{5.1}$$
or
$$\Phi(x,h)=\sum_{l=0}^\infty h^l P_l(x)\quad\text{for}\quad |h|\lt 1\tag{5.2}$$
In order for the question I have to make any sense whatsoever I must include some background information as written in my textbook:



Now, suppose that I have a potential $V_q$ which is given by
$$V_q=\frac{q}{\sqrt{R^2-2aR\cos\theta+a^2}}$$ and I wish to write this in terms of the generating function.
So applying the same method as what is shown in the image extract from my textbook I find that:
$$V_q=\frac{q}{\sqrt{R^2-2aR\cos\theta+a^2}}=\frac{q}{R\sqrt{1-2\left(\frac{a}{R}\right)\cos\theta+{\left(\frac{a}{R}\right)}^2}}$$
Now letting $h=\dfrac{a}{R}$ and $x=\cos\theta$ then 
$$\begin{align}V_q &=\frac{q}{R\sqrt{1-2hx+h^2}}\\&=\frac{q}{R}(1-2xh+h^2)^{-1/2}\\&=\frac{q}{R}\Phi(x,h)\\&=\frac{q}{R}\sum_{l=0}^\infty h^l P_l(x)\\&=\frac{q}{R}\sum_{l=0}^\infty \frac{a^l}{R^l}P_l(\cos\theta)\\&=\fbox{$\color{blue}{q\sum_{l=0}^\infty \frac{a^l}{R^{l+1}}P_l(\cos\theta)}$}\end{align}$$

The problem is that the textbook answer shown below is different from my blue boxed formula:

So basically the powers of $a$ and $R$ are reversed. Does anyone have any idea what I'm doing wrong?

EDIT:
I have included an image that shows the initial problem for clarity:

Thanks.

In the context of the final boxed answer, is $a$ actually less than $R$? This is implicitly assumed by your method when you factored $R^2$ from the square root (because $h$ must be less than $1$). Generally the choice of pulling out a factor of $R^2$ or a factor of $a^2$ is determined by which one is larger, i.e., the solution depends on the region of interest.
Notice that in the example provided there is no information in the problem to distinguish between $r$ and $R$. Between steps (5.13) and (5.14) the author explicitly states that he is doing the case for when $\|r\|<\|R\|$. It really does matter which is larger, because if $a<R$ the final boxed solution will not converge. 
The problem is to find the potential outside the sphere. This means $a$ is larger than  $R$
