How to find a sequence of step functions that converges to $\frac{1}{\sqrt{x}}$? 
Definition:Let $v:(a,b)\to\mathbb{R}$. If there exists a partition $P$ of the interval $(a,b)$ such that $v$ is constant in each subinterval of $P$, we say that $v$ is a step function.

Let $u:(0,1)\to\mathbb{R}$ be the function given by $u(x)=1/\sqrt{x}$. I'm trying to find a sequence $u_n:(0,1)\to\mathbb{R}$ of step functions that converges to $u$ almost everywhere.
I think I got a solution for some simplest cases, like $u(x)=x$, $u(x)=2x$, $u(x)=x^2$, by taking $$u_n(x)=\left\{\begin{matrix}
u\left(\frac{1}{n}\right) & \text{if }0<x\leq\frac{1}{n}\\ 
u\left(\frac{2}{n}\right) & \text{if }\frac{1}{n}<x\leq\frac{2}{n}\\ 
 \vdots& \\ 
u(1) & \text{if }\frac{n-1}{n}<x<1
\end{matrix}\right.$$ But I don't know how to solve the case $u(x)=1/\sqrt{x}$.
Thanks.
 A: IMHO, the easiest way is to do something like
$$u_n(x) = \min\left( n, 2^{-n} \Big\lfloor 2^n \frac{1}{\sqrt{x}} \Big\rfloor \right)$$
The use of the factor $2^n$ instead of $n$ make you easier to justify for fixed $x$, your $u_n(x)$ is a monotonic increasing sequence in $n$. The use of $2^{-n} \lfloor 2^{n} \cdots \rfloor$ allow you to conclude for large enough $n$, the difference between $u_n(x)$ and $\frac{1}{\sqrt{x}}$ is bounded by $2^{-n}$ and hence
$u_n(x)$ converges pointwise to $\frac{1}{\sqrt{x}}$ for any $x > 0$.
A: Consider the usual step function approach for $\left[\dfrac 1 n,1\right)$, let the step function be $0$ on $(0,n^{-1})$. That is, partition $[n^{-1},1)$ into small segments and take say the $\inf$ of your function to be the constant of the step in the interval. As $n$ grows larger, you will be able to approach $0$ nicely. Rememeber all we want is a pointwise limit. If you want to save some work, you can argue like this. For each $k$, there is a sequence of step functions $s_{k,n}$ that converge to $x^{-1/2}$ on $[k^{-1},1)$. Consider the sequence $t_n=s_{n,n}$ where we define the step to be $0$ where we didn't define it before.
