How can I solve a functional equation with domain restrictions?

Consider the so-called Cantor function.

Plot[CantorStaircase[x], {x, 0, 1}] 

As the following plot confirms it does have the functional properties.

Plot[{CantorStaircase[1-x]-(1-CantorStaircase[x]),CantorStaircase[x/3]-CantorStaircase[x]/2}, {x, 0, 1}] 

Moreover, it is CantorStaircase[6/7] equal to $3/4$.

It can be shown (see Chalice, D. R. "A Characterization of the Cantor Function." Amer. Math. Monthly 98, 255-258, 1991.) that this is the only real-valued increasing function satisfying your equations.

I'm not sure if RSolve is able to recover that kind of function.


There can be no solution, because the both equations contradict each other.

First get solution for second equation.

eqs = {f[1 - x] == 1 - f[x], f[x/3] == 1/2 f[x]};

fs = f /. First@RSolve[eqs[[2]], f, x]

(*   Function[{x}, 2^(-1 + Log[x]/Log[3]) C[1]]   *)

Solve for the constant C[1] with equation 1 and you see,that C[1] depends on x, but it should be constant.

sol = First@Solve[eqs[[1]] /. f -> fs, C[1]]

(*   {C[1] -> 2/(2^(Log[1 - x]/Log[3]) + 2^(Log[x]/Log[3]))}   *)

Plot[C[1] /. sol, {x, 0, 1}]