Main Question
-------------


This question is about finding *explicit*, *calculable*, and *fast* error bounds when approximating continuous functions with polynomials to a user-specified error tolerance.




---


EDIT (Apr. 23): See also a [revised version of this question](https://mathoverflow.net/questions/442057/explicit-and-fast-error-bounds-for-approximating-continuous-functions) on *MathOverflow*.


Also: The other answer to this question claims that the result it mentions "should be easy to map ... to [0, 1]". I don't see how, especially since not every function that meets the result's assumptions on [0, 1] can be extended to one that does so on [-1, 1]. In addition, does the result on the polynomial interpolant relate to the "exact" Chebyshev coefficients, or the "approximate" and "easier-to-compute" coefficients? (These and other unsure points on the Chebyshev method have made me prefer other methods to approximate functions — especially those that don't introduce transcendental functions, and these other methods include linear combinations and iterated Boolean sums of Bernstein polynomials.)


In addition, a comment to that answer mentions choosing "rational nodes close to the Chebyshev nodes" as a way of avoiding transcendental functions. But are there results on the use of such rational nodes to approximate continuous functions and, if so, do they provide explicit error bounds (with no hidden constants) at the rate $O(1/n^{r/2})$ for the class of functions with continuous $r$-th derivative on [0, 1]?




---


In this question:


* A polynomial $P(x)$ is written in *Bernstein form of degree $n$* if it is written as $P(x)=\sum\_{k=0}^n a\_k {n \choose k} x^k (1-x)^{n-k},$ where $a\_0, ..., a\_n$ are the polynomial's *Bernstein coefficients*.
* For the *Bernstein polynomial* of $f(x)$ of degree $n$, $a\_k = f(k/n)$.


Let $f:[0,1]\to [0,1]$ be continuous and polynomially bounded (both $f$ and $1-f$ are bounded below by min($x^n$, $n(1-x)^n$) for some integer $n$), let $r\ge 3$, and denote the Bernstein polynomial of degree $n$ of a function $g$ as $B\_n(g)$.


Given that $f$ has a continuous $r$-th derivative (or has a Lipschitz continuous $(r-1)$-th derivative), are there results that give a sequence of polynomials $P\_n$ with the following error bound?


$$| f(x) - P\_n(f)(x) | \le \epsilon(f, n, x) = O(1/n^{r/2}),$$ where:


1. $\epsilon(f, n, x)$ is a fully determined function, with all constants in the expression having a **known exact value or upper bound**.
2. $P\_n(f)(x)$ is an approximating polynomial of degree $n$ that can be readily rewritten to a polynomial in Bernstein form with coefficients in $[0, 1]$. Preferably, $P\_n(f)$ has the form $B\_n(W\_n(f))$ where $W\_n(f)$ is easily computable from $f$ using rational arithmetic only (see "Remarks", later).


One way to answer this (see [this question](https://math.stackexchange.com/questions/3904732/what-are-ways-to-compute-polynomials-that-converge-from-above-and-below-to-a-con)) is to find a sequence $W\_n(f)$ and an explicit and tight upper bound on $C\_1>0$ such that, for each integer $n\ge 1$ that's a power of 2— $$\max\_{0\le k\le 2n}\left|\left(\sum\_{i=0}^k \left(W\_n\left(\frac{i}{n}\right)\right) {n\choose i}{n\choose {k-i}}/{2n \choose k}\right)-W\_{2n}\left(\frac{k}{2n}\right)\right|\le \frac{C\_1 M}{n^{r/2}},$$ where $M$ is the maximum absolute value of $f$ and its derivatives up to the $r$-th derivative (or, respectively, the maximum of $|f|$ and the Lipschitz constants of $f$ and its derivatives up to the $(r-1)$-th derivative).


Then $| f(x) - B\_n(W\_n(f))(x) | \le \frac{C\_1}{1-\sqrt{2/2^{r+1}}}\frac{M}{n^{r/2}}=O(1/n^{r/2})$ (see Lemma 3 in "[Proofs for Polynomial-Building Schemes](https://peteroupc.github.io/bernsupp.html#Proofs_for_Polynomial_Building_Schemes)), although this is only guaranteed to work for power-of-2 values of $n$. For example, $W\_n$ can be $2f-B\_n(f)$ and $r$ can be 3 or 4, or $W\_n$ can be $B\_n(B\_n(f))+3(f-B\_n(f))$ and $r$ can be 5 or 6.


### Motivation


My motivation for this question is to implement "[*approximate Bernoulli factories*](https://peteroupc.github.io/bernsupp.html#Approximate_Bernoulli_Factories)", or algorithms that toss heads with a probability equal to a polynomial in Bernstein form that comes within $\epsilon$ of a continuous function $f(x)$. This involves finding a reasonably small degree $n$ of that polynomial, then the algorithm works as follows:


1. Flip the coin $n$ times, count the number of heads as $h$.
2. With probability equal to the $h$-th Bernstein coefficient, return heads; otherwise tails.


Note that the algorithm requires finding only one Bernstein coefficient per run. And for ordinary Bernstein polynomials, finding it is trivial — $f(h/n)$ — but the degree $n$ can be inordinate due to Bernstein polynomials' slow convergence; for example, if $\epsilon=0.01$ and $f$ is Lipschitz with constant 1, the required polynomial degree is 11879.


* Approximating $f$ with a rational function is also interesting, but is outside the scope of this question.
* *Exact* Bernoulli factories require a slightly different approach to finding the polynomials; see [another question of mine](https://math.stackexchange.com/questions/3904732/what-are-ways-to-compute-polynomials-that-converge-from-above-and-below-to-a-con).


### Polynomials with faster convergence than Bernstein polynomials


As is known since Voronovskaya (1932), the Bernstein polynomials converge uniformly to $f$, in general, at a rate no faster than $O(1/n)$, regardless of $f$'s smoothness, which means that it won't converge in a finite expected running time. (See also a [related question](https://math.stackexchange.com/questions/3889382/bound-on-approximation-error-of-bernstein-polynomial) by Luis Mendo on ordinary Bernstein polynomials.)


But Lorentz (1966, "The degree of approximation by polynomials with positive coefficients") has shown that if $f(x)$ is positive (the case that interests me) and has $k$ continuous derivatives, there are polynomials with non-negative Bernstein coefficients that converge to $f$ at the rate $O(1/n^{k/2})$ (and thus can be faster than the $O(1/n^{2+\epsilon})$ needed for a finite expected running time, depending on $f$).\*


Thus, people have developed alternatives, including *iterated Bernstein polynomials*, to improve the convergence rate. These include:


* Micchelli, C. (1973). The saturation class and iterates of the Bernstein polynomials. Journal of Approximation Theory, 8(1), 1-18.
* Guan, Zhong. "[Iterated Bernstein polynomial approximations](https://arxiv.org/pdf/0909.0684)." arXiv preprint arXiv:0909.0684 (2009).
* Güntürk, C. Sinan, and Weilin Li. "[Approximation with one-bit polynomials in Bernstein form](https://arxiv.org/pdf/2112.09183)" arXiv preprint arXiv:2112.09183 (2021).
* The "Lorentz operator": Holtz, Olga, Fedor Nazarov, and Yuval Peres. "[New coins from old, smoothly](https://link.springer.com/article/10.1007/s00365-010-9108-5)" Constructive Approximation 33, no. 3 (2011): 331-363.
* Draganov, Borislav R. "On simultaneous approximation by iterated Boolean sums of Bernstein operators." Results in Mathematics 66, no. 1 (2014): 21-41.


Usually, papers like those express a bound on the error when approximating a function with polynomials as follows: $$| f(x) - P\_n(f)(x) | \le c\_n \epsilon(f, n, x),$$ where $\epsilon(f, n, x)$ is a fully determined function, $c\_n>0$ is a constant that may depend on $n$, and $P\_n(f)(x)$ is an approximating polynomial of degree $n$.


There are results where the error bound $\epsilon(.)$ is in $O(1/n^{k/2})$, but in all those results I've seen so far (e.g., Theorem 4.4 in Micchelli; Theorem 5 in Güntürk and Li), $c\_n$ is unknown, and no upper bound for $c\_n$ is given by the results in the papers above, so that the error bound is unimplementable and there is no way of knowing beforehand whether $P\_n$ will come close to $f$ within a user-specified error tolerance. (There is also a separate matter of rewriting the polynomial to its Bernstein form, but this is much more manageable, especially with the Lorentz operator.)


### Remarks


* I prefer approaches that involve only rational arithmetic and don't require transcendental or trigonometric functions to build the Bernstein-form polynomials.


	+ Unlike with rational arithmetic (where arbitrary precision is trivial thanks to Python's `fractions` module), transcendental and trig. functions require special measures to support arbitrary accuracy, such as constructive/recursive reals — floating point won't do for my purposes.
	+ In general, "rounding" a polynomial's coefficients or "nodes" to rational numbers will add a non-trivial error that, for my purposes, has to be accounted for in any error bound.




---


\* If the polynomials are not restricted in their coefficients, then the rate $O(1/n^k)$ is possible (e.g., DeVore and Lorentz 1993). But this result is not useful to me since my use case (approximate Bernoulli factories) requires the polynomials to have Bernstein coefficients in $[0, 1]$.



Explicit and fast error bounds for polynomial approximation
If $f, f', \dotsc, f^{(\nu-1)}$ are all absolutely continuous on $[-1, 1]$, and $f^{(\nu)}$ has bounded variation $V$ on $[-1, 1]$, where $\nu \ge 1$, then the polynomial interpolant $p\_n$ of degree $n > \nu$ through the Chebyshev points of the second kind,
$$ p\_n(x\_j) = f(x\_j), \quad x\_j = \cos \tfrac{j\pi}{n}, \quad j=0,\dotsc,n, $$
satisfies the bound
$$ \sup\_{-1 \le x \le 1} | f(x) - p\_n(x)| \le \frac{4V}{\pi \nu (n - \nu)^\nu}. $$
See Theorem 7.2, equation (7.5) of [1].


It should be easy to map the result to [0, 1]. If all you know is that $f$ has $k$ continuous derivatives, then you can take $\nu = k-1$, provided $k \ge 2$. The convergence rate $O(n^{-(k-1)})$ is faster than you asked for when $k > 2$ (and equal at $k=2$).


I am unclear exactly what you mean by being "readily rewritten" to the Bernstein polynomial basis. One explicit possibility: you can use a discrete Fourier transform (specifically, the FFT) to recover the coefficients of the Chebyshev series of $p\_n$ from the values at the Chebyshev points above (again, see [1]), then use an explicit expansion of the Chebyshev polynomials in the Bernstein basis (e.g., the one on the [Wikipedia page for the Bernstien polynomials](https://en.wikipedia.org/wiki/Bernstein_polynomial)).


[1] *Trefethen, Lloyd N.*, Approximation theory and approximation practice, Other Titles in Applied Mathematics 128. Philadelphia, PA: Society for Industrial and Applied Mathematics (SIAM) (ISBN 978-1-611972-39-9/pbk). 305 p. (2013). [ZBL1264.41001](https://zbmath.org/?q=an:1264.41001).


