# Loops when drawing constantly changing angles and lines. [closed]

I start by drawing a line of 1 unit on the $x$ axis. I turn left (from the perspective of an ant on the line) by an angle of $\alpha$ and I draw a second segment of length $u$ from my endpoint of the first segment. I then turn another angle $\alpha$ and then draw a $3^{rd}$ segment of length 1, etc. alternating between segments of length $1,u,1,u,...$ and rotating by a fixed angle each time. I am interested in when does this process returns to the origin and how long does it take for it to return when it does.

## closed as off-topic by Matthew Conroy, Claude Leibovici, JonMark Perry, user91500, Arnaud D.Sep 19 '17 at 20:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Matthew Conroy, Claude Leibovici, Arnaud D.
If this question can be reworded to fit the rules in the help center, please edit the question.

## 3 Answers

We work in the complex plane. Let $z=e^{i\alpha}$. Then the path is: $$1+uz+z^2+uz^3+z^4+uz^5+\cdots$$ If $1+uz=0$, meaning $u=1$ and $\alpha=\pi$, then we return to $0$ after $2$ steps. Otherwise, assume that $1+uz\neq0$.

Suppose the path returns to $0$ after $2N$ steps for $N>1$. Then we can solve for this: $$0=(1+uz)\sum_{k=0}^{N-1}z^{2k}$$ Divide out $(1+uz)$: $$0=\sum_{k=0}^{N-1}z^{2k}$$ This is true if and only if $z^{2N}=1$ and $z^2\neq1$. In other words, $\alpha$ is a multiple of $\pi/N$, but not $0$ or $\pi$. Note that $u$ is irrelevant!

Tackling an odd number is harder. Suppose the path returns to $0$ after $2N+1$ steps. Then: $$0=z^{2N+1}+(1+uz)\sum_{k=0}^{N-1}z^{2k}=z^{2N+1}+(1+uz)\frac{1-z^{2N}}{1-z^2}$$ $$0=z^{2N+1}-z^{2N+3}+1+uz-z^{2N}-uz^{2N+1}$$ That's a really messy equation, and I'm not sure if there's a simple class of solutions.

The named system of equations solving for $n=2k,\alpha,u$ should be: $$u \sum_{i=0}^k \cos((2k+1)\alpha)+\sum_{i=0}^k \cos(2k\alpha)=0\\ u \sum_{i=0}^k \sin((2k+1)\alpha)+\sum_{i=0}^k \sin(2k\alpha)=0$$ Hence the solution for a given $k$, if exists, is given by: $$u = -\frac{\sum_{i=0}^k \cos(2k\alpha)}{\sum_{i=0}^k \cos((2k+1)\alpha)}\\ \frac{\sum_{i=0}^k \cos(2k\alpha)}{\sum_{i=0}^k \cos((2k+1)\alpha)} = \frac{\sum_{i=0}^k \sin(2k\alpha)}{\sum_{i=0}^k \sin((2k+1)\alpha)}$$ Which as you see, would have a closed form for some circular symmetry values for $\alpha$....

The loci are polygons containing start point on the circle as we know the sum of external angles $=360^0$ for a full closed regular polygon. In general it would be infinite sided irregular polygon. The "polygon" can be drawn even on BASIC.

Diameter $D$ of approximate circum-circle so formed $=\dfrac{1+u}{2 \alpha}$, Full Arc length $=\pi D$ to return to the start point as shown.

It can be seen that when $\alpha$ is small the locus tends to a circle.

When $n$ is integer, rotation angle at each vertex of polygon $\alpha =2\pi/(2n)$ when repeated forms a regular polygon.

Circles Tgt to X-axis