<s>[INST] Help Finding Closed Form for Function of Decreasing Half Steps I would like to know if there is a closed form for this function:
$ 
f(x) = 
    \begin{cases}
      \frac{1}{2}, & \text{if}\ 0 \leq x < \frac{1}{2} \\
      \frac{1}{4}, & \text{if}\ \frac{1}{2} \leq x < \frac{1}{2} + \frac{1}{4} \\
      \frac{1}{8}, & \text{if}\ \frac{1}{2} + \frac{1}{4} \leq x < \frac{1}{2} + \frac{1}{4} + \frac{1}{8} \\
      \frac{1}{16}, & \text{if}\ \frac{1}{2} + \frac{1}{4} + \frac{1}{8} \leq x < \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} \\
...
    \end{cases}
$
Image of function
 [/INST] 
Fig. 1: Graphical representation of function $f$ (formula (0)). The red vertical segments are a plotting artefact.
Here is a solution:
$$y=f(x)=2^{\lfloor\log_2(1-x)\rfloor}\tag{0}$$
where $\lfloor \cdots \rfloor$ is the floor function and $\log_2$ is the logarithm function with base $2$.
Remark: Consideration of the extreme cases of the "integer part of $a$", which can be $a$ or $a-1$, one gets

*

*

*

*$ \ \ y=2^{\log_2(1-x)}=1-x$ or



*


*$ \ \ y=2^{\log_2(1-x)-1}=\tfrac12 (1-x)$
which are the equations of the lines containing resp. the "upper" and "lower" points of discontinuity of the graphical representation (dotted blue lines in the figures).
Proof of formula (0):

Fig. 2: Graphical representation of function $g$, given by formula (1), related to function $f$ by $f(x)=g(1-x)$.
In fact, it will be equivalent and simpler to work on function $g$ with graphical representation given in Fig. 2 and establish that its equation is
$$y=g(x)=2^{\lfloor\log_2(x)\rfloor}\tag{1}$$
Function $g$ is defined as taking values $$y=\tfrac{1}{2^{n+1}}\tag{2}$$ for
$$\tfrac{1}{2^{n+1}} < x \le \tfrac{1}{2^{n}}\tag{3}$$
Remark: $g$ is in fact a rather well known function giving the highest power of 2 smaller than or equal to a given number $x$.
Let us attempt to express $n$ as a function of $x$.
Applying the increasing function  $\log_2$ to this double inequation, we get:
$$-(n+1) < \log_2(x) \le -n$$ or, reversing the sign and the direction of inequalities:
$$n \le -\log_2(x) < n+1$$
Otherwise said: $$n=\lfloor -\log_2(x) \rfloor.$$
Plugging this expression of $n$ into relationship (2) gives:
$$y=2^{-(n+1)}=y=2^{-\lceil -\log_2(x) \rceil}$$
which is equivalent to expression (1) (where $\lceil...\rceil$ is the "ceiling" function).
</s>