Solution (source code)

= Solution

For an axisymmetric separated solution of the <Laplace equation> whose angular factor is the <Legendre polynomial> $P_n(\cos\theta)$, the radial <ordinary differential equation> has the two powers $r^n$ and $r^{-n-1}$. Thus
$$
\boxed{\Phi(r,\theta,\phi)=(A r^n+B r^{-n-1})P_n(\cos\theta)}
$$
for constants $A,B$.

Write $x=\cos\theta$. Since $3\cos(2\theta)=6x^2-3=4P_2(x)-P_0(x)$, only the <spherical harmonics> of degrees zero and two occur. The degree-zero radial coefficient satisfying its two <Dirichlet boundary conditions> is $1-2/r$. For degree two, write $Cr^2+Dr^{-3}$; then
$$
C+D=4,
\qquad 4C+\frac D8=0,
$$
so $C=-4/31$ and $D=128/31$. By linearity and uniqueness of this <boundary value problem>,
$$
\boxed{\Phi(r,\theta)=1-\frac2r+
\frac4{31}\left(\frac{32}{r^3}-r^2\right)P_2(\cos\theta)}.
$$
Direct substitution at $r=1,2$ verifies both boundary values.