Let $t\_1 < t\_2 < \cdots <t\_m$ be real, and $X = \cup\_{i=1}^{m-1} (t\_i, t\_{i+1})$ be a union of real open intervals. Let $f:X \rightarrow \{-1, 1\}$ be any piecewise constant function of form
$$
f(x) = 
 \begin{cases} 
 a\_1 & \text{ if } t\_1 < x < t\_2 \\
 a\_2 & \text{ if }t\_2 < x < t\_3 \\
 \vdots \\
a\_{m-2} & \text{ if } t\_{m-2} < x < t\_{m-1} \\ 
 a\_{m-1} & \text{ if } t\_{m-1} < x < t\_m 
 \end{cases}
$$
Where $a\_i \in \{-1, 1\}$, and $a\_{i} = -a\_{i+1}$ for $i = 1, ..., m-1$.


I have a number of questions regarding polynomial approximations of such a function $f$:


1. Can we always find a sequence of polynomials $(p\_n)\_{n=1}^\infty$ so that $(p\_n)\_{n=1}^\infty$ converge pointwise to $f$, and $|p\_n(x) - f(x)| \leq 1$ for all $x \in X$ and $n \in \mathbb{N}$?
2. If so, are such polynomials easy to find and construct (i.e. do we have closed form solutions)?
3. How quickly do we get convergence?


I am aware that, upon picking a suitable inner product, we can use any collection of orthonormal polynomials to make approximations of functions. For example I know the Chebyshev, Bernstein, Jacobi etc. polynomials can be used to approximate continuous functions on bounded intervals, but I have found no theorem that says we can use these to construct approximations for arbitrary piecewise constant functions like the one given above.


Indeed, it is easy to find a polynomial approximation for the Heaviside Step function for example, however it is unclear how, or if this an be done for more complicated step functions.



Determining polynomial approximations of piecewise constant functions
The polynomial $Q(y):=\frac43y-\frac13 {y^3}$ is increasing on the interval $[-1,1]$; it has fixed points $0$ and $\pm1$, and $\text{sgn }( Q(y)-y )=\text{sgn}y$. Thus the iterates of $Q$ starting from any $y\in [-1,1]\setminus\{0\}$ converge monotonically to $\text{sgn } y$ (in fact with exponential rate given by $Q'(\pm1)=\frac13$, and uniformly away from $0$
).


Assuming w.l.o.g $a\_i=(-1)^i$, your step function can be written $f(x):= \text{sgn} P(x)$ with $P(x):= \prod\_{i=1}^m(t\_i-x)$, for any $x\in X$. If we choose any $M\ge \|P(x)\|\_{\infty,X}$ the polynomial sequence of iterates $Q^{n}\big( {P(x)}/ M\big)$ converges to $f$ on $X$; in fact increasing/decreasing between consecutive nodes, and uniformly on compacts set of $X$.


