A Mysterious Function

The function f[x] is defined for x in [0,1] by adding a zero before each digit in the decimal expansion of x. For example, f[.0123] = .00010203. To creat the function f[x] in Mathematica we should use the built-in function RealDigits[x]which returns a list of (non-zero) digits in x and  the appropriate exponent to give the correct number of initial zeros.

RealDigits[ .0123]

If x = .abc... = a 10^-1 + b^10^-2 + c^-3 + ..., then
f[x] = a 10^-2 + b 10^-4 + c 10^-6 + ... We use double brackets to pick out the pieces of the lists returned by RealDigits[]. The list of digits is stored in d and the exponent in e. We then compute f[x] as a sum of the digits in d mutiplied by 10 raised to doubled exponents:

f[x_]  :=  
      (r =   RealDigits[x];  d  =  r[[1]]; e  = r[[2]]; 
        Sum[ d[[n]]*10.0^(2 (e - n)),  {n, 1, Length[d]}])

f[ .0123]

The plot looks like a step function:

\(p\  = \ 
      Plot[f[x], \ {x, 0, 1}, 
		\ \ \ \ PlotRange -> {0, 0.1}, 
        PlotPoints -> 100, \ AspectRatio -> 1]\)

If you look closely, each step is also jageed. If we zoom into the subinterval [0,0.1] we see a similar picture:

Show[p, PlotRange -> {{0,  .1}, {0,  .001}},  AspectRatio -> 1]