# Primary Bulb
The child bulb of the period \(1\) cardioid at internal angle \(\frac{p}{q}\) has external angles:
\[(.\overline{b_0 b_1 \ldots b_{q-3} 0 1}, .\overline{b_0 b_1 \ldots b_{q-3} 1 0})\]
where
\[b_0 b_1 \ldots = \operatorname{map} \left(\in \left(1 - \frac{p}{q}, 1\right)\right) \circ \operatorname{iterate} \left(+\frac{p}{q}\right) \$ \frac{p}{q}\]
# 1 Haskell Code
import Data.Fixed (mod')
import Data.List (genericTake)
import Data.Ratio (denominator)
type InternalAngle = Rational
type ExternalAngle = ([Bool], [Bool])
primaryBulb
:: InternalAngle
-> (ExternalAngle, ExternalAngle)
primaryBulb pq
= ( ([], bs ++ [False, True])
, ([], bs ++ [True, False])
)
where
q = denominator pq
bs
= genericTake (q - 2)
. map (\x -> 1 - pq < x && x < 1)
. iterate (\x -> (x + pq) `mod'` 1)
$ pq
# 2 Examples
Consider the bulb at internal angle \(\frac{p}{q} = \frac{2}{5}\):
\[\begin{aligned} r_0 = \frac{2}{5} &\not\in \left(1 - \frac{2}{5},1\right) &\therefore b_0 = 0 \\ r_1 = \frac{4}{5} & \in \left(1 - \frac{2}{5},1\right) &\therefore b_1 = 1 \\ r_2 = \frac{1}{5} &\not\in \left(1 - \frac{2}{5},1\right) &\therefore b_2 = 0 \end{aligned}\]
Therefore the external angles for the \(\frac{2}{5}\) bulb are:
\[\left( .\overline{01001}, .\overline{01010} \right)\]