--- title: "Dyadic expansion with R" date: "2016-08-08" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE, collapse=TRUE, fig.path="./assets/fig/dyadic-", fig.align="center") fscale <- 1 # scale for figures ``` We provide a function that computes the dyadic representation of a real number in the interval $[0,1]$. Then we give an implementation of two transformations of the set ${\{0,1\}}^\mathbb{N}$ which are well-known in ergodic theory: the dyadic odometer and the Pascal transformation. For each of these transformations, we plot the graph of the conjugate transformation of $[0,1]$ obtained by the dyadic representation. ## Dyadic expansion Every real number $u \in [0,1]$ has a *dyadic expansion* (or *binary expansion*): $$ u = \frac{\epsilon_1}{2} + \frac{\epsilon_2}{2^2} + \frac{\epsilon_3}{2^3} + \ldots $$ where $\epsilon_i=0$ or $1$. We say that the sequence $(\epsilon_1, \epsilon_2, \ldots)$ is the *dyadic representation* of $u$. The `num2dyadic` function below returns the dyadic representation of $u \in [0,1]$. ```{r} num2dyadic <- function(u, nmax=1024L){ out <- integer(nmax) i <- j <- 0L while(u>0 && i