Step 1: Write the boundary data in polar form.
Put $x = r\cos\theta$ and $y = r\sin\theta$. On the boundary circle $r = 1$, the given data becomes
\[ f(\theta) = \cos^2\theta - \sin^2\theta = \cos(2\theta) \]
using the double angle identity. So the boundary function is a single cosine harmonic, $f(\theta) = \cos(2\theta)$.
Step 2: Recall the general harmonic solution in polar coordinates.
Any function that solves Laplace's equation inside a disc and stays finite at the center can be written as a Fourier series in $\theta$ with coefficients that are powers of $r$:
\[ u(r,\theta) = \frac{a_0}{2} + \sum_{n=1}^{\infty} r^n \left( a_n \cos(n\theta) + b_n \sin(n\theta) \right) \]
This form works because each term $r^n\cos(n\theta)$ and $r^n\sin(n\theta)$ individually satisfies Laplace's equation, and only non negative powers of $r$ stay finite as $r \to 0$.
Step 3: Match the boundary series with $f(\theta) = \cos(2\theta)$.
On $r = 1$, the series must equal $\cos(2\theta)$. Comparing term by term, every coefficient is zero except $a_2 = 1$. So the solution collapses to a single term:
\[ u(r,\theta) = r^2 \cos(2\theta) \]
Step 4: Convert the two points to polar form and substitute.
The point $\left(\frac{1}{2},0\right)$ has $r = \frac{1}{2}$, $\theta = 0$:
\[ u\left(\frac{1}{2},0\right) = \left(\frac{1}{2}\right)^2 \cos(0) = \frac{1}{4}(1) = \frac{1}{4} \]
The point $\left(0,\frac{1}{2}\right)$ has $r = \frac{1}{2}$, $\theta = \frac{\pi}{2}$:
\[ u\left(0,\frac{1}{2}\right) = \left(\frac{1}{2}\right)^2 \cos(\pi) = \frac{1}{4}(-1) = -\frac{1}{4} \]
These match the values found by the direct substitution method, which confirms the harmonic extension is correct.
Step 5: Final Answer.
\[ 4\left(\frac{1}{4} - \left(-\frac{1}{4}\right)\right) = 4 \times \frac{1}{2} = 2 \]
\[ \boxed{2} \]