# mathr / blog / #

## Interior coordinates in the Mandelbrot set There is an algorithm to find points on the boundary of the Mandelbrot set, given a particular hyperbolic component and the desired internal angle. It involves Newton's method in two complex variables to solve

$F^p(z,c) = z \\ \frac{\partial}{\partial z} F^p(z,c) = b$

where $$F^0(z,c) = z$$ and $$F^{q+1}(z,c) = F^q(F(z,c)^2+c)$$, $$p$$ is the period of the target component, and $$b=e^{2 \pi i \theta}$$ with the $$\theta$$ the desired internal angle. The resulting $$c$$ is the coordinates of the point on the boundary. It can also be modified to find points in the interior, simply set $$b = r e^{2 \pi i \theta}$$ with $$\left|r\right| \le 1$$.

After seeing this fractal Mandelbrot in an IRC channel, I wondered if it was possible to invert the algorithm, namely find $$b$$ given $$c$$, and use $$b$$ as polar texture coordinates to place copies of an image inside the Mandelbrot fractal. The answer is yes, and in some sense it's actually easier than the other direction.

The algorithm I developed works like this:

1. When $$c$$ is outside the Mandelbrot set, give up now;
2. For each period $$p$$, starting from $$1$$ and increasing:
1. Find $$z_0$$ such that $$F^p(z_0,c) = z_0$$ using Newton's method in one complex variable;
2. Find $$b$$ by evaluating $$\frac{\partial}{\partial z} F^p(z,c)$$ at $$z_0$$;
3. If $$\left|b\right| \le 1$$ then return $$b$$, otherwise continue with the next $$p$$.

I wrote this implementation.