Find the distance travelled by an ant in the coordinate plane

An ant is standing on the origin. It begins by walking 1 unit in the positive $x$-direction and then turns $45$ degrees counterclockwise and walks $\dfrac{1}{2}$ units in that direction. The ant then turns another $45$ degrees and walks $\dfrac{1}{3}$ units in that direction. The ant keeps doing this endlessly. How far is the ant's final position from the initial position?

I think I should let the origin be $(0,0)$ and calculate the coordinates of the points that ant reaches each time it turns. I believe the $x$-coordinate at the $n$th step is $\sum_{k=1}^n\dfrac{cos(\dfrac{\pi}{4}(k-1))}{k}$ and the $y$-coordinate at the $n$th step is $\sum_{k=1}^n\dfrac{sin(\dfrac{\pi}{4}(k-1))}{k}$.


The problem is amenable to some simple complex number analysis (you have to work in radian measure, note that $45^{\circ} = \frac{\pi}{4}$).

Each step can be characterised as a vector in the complex plane. The first step is $\displaystyle 1 = 1e^{i0}$, the second is $\displaystyle \frac 12e^{i\frac{\pi}{4}}$, and the $n$th step is $\displaystyle \frac 1n e^{i\frac{(n-1)\pi}{4}}$. The final position is the infinite sum of all of these complex numbers.

Let $\displaystyle z = e^{i\frac{\pi}{4}}$.

Then define a series sum $\displaystyle S(z) = 1 + \frac 12 z + \frac 13 z^2 + \frac 14 z^3 + ...$

Note that $zS(z) = z + \frac 12 z^2 + \frac 13 z^3 + \frac 14 z^4 + ...$

And now observe: $(zS(z))' = 1 + z + z^2 + z^3 + z^4 + ... = \frac 1{1-z}$, where convergence is assured for complex $|z| < 1$.

By integrating and rearranging, we find, $\displaystyle S(z) = - \frac 1z \ln(1-z)$. (The constant of integration is easily shown to be zero).

Now find $|\displaystyle S(e^{i\frac{\pi}{4}})|$, which is the distance of the final position of the ant from the origin.

$|\displaystyle S(e^{i\frac{\pi}{4}})| = |-e^{-\frac{i\pi}{4}}\ln(1-e^{i\frac{\pi}{4}})|$

Since $\displaystyle |z_1z_2| = |z_1||z_2|$, the above is equal to $\displaystyle |-e^{-\frac{i\pi}{4}}||\ln(1-e^{i\frac{\pi}{4}})| = |\ln(1-e^{i\frac{\pi}{4}})|$

(since $\displaystyle |-e^{-\frac{i\pi}{4}}| = 1$)

To find $\displaystyle |\ln(1-e^{i\frac{\pi}{4}})|$, we first express $\displaystyle 1-e^{i\frac{\pi}{4}}$ in the form $re^{i\theta}$.

$\displaystyle 1-e^{i\frac{\pi}{4}} = 1-\cos \frac{\pi}{4} - i\sin\frac{\pi}{4}$

Now $\displaystyle r = \sqrt{(1-\cos \frac{\pi}{4})^2 + (\sin\frac{\pi}{4})^2} = \sqrt{2 - 2\cos \frac{\pi}{4}} = \sqrt{2-\sqrt 2}$

and $\displaystyle \theta = \arctan{\frac{\sin\frac{\pi}{4}}{1-\cos \frac{\pi}{4}}} = \arctan (\sqrt 2 + 1)$

and $\displaystyle \ln(re^{i\theta}) = \ln r + i\theta$, giving:

$\displaystyle |\ln(1-e^{i\frac{\pi}{4}})| = |\frac 12 \ln{(2-\sqrt 2)} + i\arctan{(\sqrt 2 + 1)}| \\= \sqrt{[\arctan(\sqrt 2 + 1)]^2 + \frac 14[\ln(2-\sqrt 2)]^2} \\= 1.20806...$