I have laplace's equation, $\nabla^2f=0$, inside a circle (radius $a$) for which the boundary condition (polar coordinates) is
$$ f(a,\phi) = \begin{cases} 1\quad \text{for $0< \phi < \pi/2$}\\ -1\quad \text{for $-\pi < \phi < -\pi/2$}\\ 0\quad \text{otherwise} \end{cases} $$
I went to solve it using the formula (for $r<a$): $$ f(r,\phi) = \frac{a^2 - r^2}{2\pi} \int^\pi_{-\pi} \frac{f(a,\phi)}{a^2 + r^2 - 2ar \cos(\phi-t)}dt $$
$$ f(r,\phi) = \frac{a^2 - r^2}{2\pi} \left[ \int^{-\pi/2}_{-\pi} \frac{-1}{a^2 + r^2 - 2ar \cos(\phi-t)}dt + \int^{\pi/2}_{0} \frac{1}{a^2 + r^2 - 2ar \cos(\phi-t)}dt\right] $$
By using the universal trigonometric substitution, I arrived at $$ f(r,\phi) = \frac{1}{\pi}\left[h\left(r,\phi,\frac{-\pi}{2}\right) - h\left(r,\phi,-\pi\right) - h\left(r,\phi,\frac{\pi}{2}\right) + h\left(r,\phi,0\right)\right] $$
Where $$ h(r,\phi,t) = \arctan\left(\frac{a+r}{a-r} \tan\left(\frac{\phi - t}{2}\right)\right) $$
Which agrees with wolfram alpha's result.
But then the plotting for various values of $r$ gave me
When I did the symbolic integration using a hp 50g calculator, a $floor$ function appeared adding to $h$.
$$ g(r,\phi,t) = h(r,\phi,t) + \pi\, \text{floor} \left( \frac{\phi-t}{2\pi} +\frac{1}{2} \right) $$
The final result being
$$ f(r,\phi) = \frac{1}{\pi}\left[g\left(r,\phi,\frac{-\pi}{2}\right) - g\left(r,\phi,-\pi\right) - g\left(r,\phi,\frac{\pi}{2}\right) + g\left(r,\phi,0\right)\right] $$
Which plotting gave me the expected result
Now I cannot understand what happenned. Why and how did (must) that floor function appear?