Question: How do we define and visualize/plot the function $\mathcal{G}:\mathbb{R}\to\mathbb{R}$?
(Definition of $\mathcal{G}$) Let $(q_t)_{t\in\mathbb{N}}$ be a numbering of the rational numbers and $k_t=2^{2^t}$, and define functions $s_t$ as follows:
If $s_0=0$ everywhere and: $${ s_{t+1}(x)=\begin{cases} q_{t/2} & x\in(q_j-1/k_t,q_j+1/k_t), \, j=1,\cdots,t, \, t \text{ is even}\\ k_t^2 & x \in(q_j-1/k_t,q_j+1/k_t), \, j=1,\cdots,t, \, t \text{ is odd}\\ s_t(x) & \text{otherwise} \end{cases}}$$ each $s_{t+1}$ agrees with $s_t$ at all real numbers except a set of measure $<1/2^t$ for big $t$, so one could consider $\mathcal{G}$ the pointwise limit of the functions $s_t$, which is defined everywhere except measure $0$ (in those bad points just define $\mathcal{G}=0$).
To answer the question, I tried the following code:
Clear["Global`*"]
enumerateRationals[n_Integer?Positive] :=
Module[{posRationals,
fullList},(*Generate enough positive rationals using the Calkin-
Wilf step*)
posRationals = NestList[1/(2 Floor[#] - # + 1) &, 1, Ceiling[n/2]];
(*Interleave:0,q1,-q1,q2,-q2...*)
fullList = Riffle[posRationals, -posRationals];
Prepend[fullList, 0][[1 ;; n]]]
r = 15;
enumerateRationals[r];
(*Generates the first r rational numbers in an enumeration*)
q[t_] := q[t] = enumerateRationals[t][[t]]
(*Takes the t-value in an enumeration*)
k[t_] := k[t] = 2^(2^t)
(*The function k[t] is important for the recurrence relation s[t]*)
s[0] == 0;
s[t_ + 1] :=
s[t + 1] =
Piecewise[{{q[t/2],
Union[Flatten[
Table[ImplicitRegion[
q[j] - 1/k[t] < x && x < q[j] + 1/k[t], {x}], {j, 1, t}]]] &&
EvenQ[t] == True}, {k[t]^2,
Union[Flatten[
Table[ImplicitRegion[
q[j] - 1/k[t] < x && x < q[j] + 1/k[t], {x}], {j, 1, t}]]] &&
OddQ[t] == True}}, s[t]]
s[3]
However, instead of getting a number from s[3], I get the following output:
s[3]
Questions From The Attempt: How do we evaluate and plot/visualize s[t] as t->Infinity to get $\mathcal{G}$ at the beginning of this post? How do we evaluate $\mathcal{G}(x)$, at any $x$-value, using the definitions above?