# Primary Bulb

The child bulb of the period 11 cardioid at internal angle pq\frac{p}{q} has external angles:

(.b0b1bq301¯,.b0b1bq310¯)(.\overline{b_0 b_1 \ldots b_{q-3} 0 1}, .\overline{b_0 b_1 \ldots b_{q-3} 1 0})

where

b0b1=map((1pq,1))iterate(+pq)$pqb_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 pq=25\frac{p}{q} = \frac{2}{5}:

r0=25(125,1)b0=0r1=45(125,1)b1=1r2=15(125,1)b2=0\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 25\frac{2}{5} bulb are:

(.01001¯,.01010¯)\left( .\overline{01001}, .\overline{01010} \right)