## Functions of bounded or vanishing nonlinearity

A natural way to measure the nonlinearity of a function ${f\colon I\to \mathbb R}$, where ${I\subset \mathbb R}$ is an interval, is the quantity ${\displaystyle NL(f;I) = \frac{1}{|I|} \inf_{k, r}\sup_{x\in I}|f(x)-kx-r|}$ which expresses the deviation of ${f}$ from a line, divided by the size of interval ${I}$. This quantity was considered in Measuring nonlinearity and reducing it.

Let us write ${NL(f) = \sup_I NL(f; I)}$ where the supremum is taken over all intervals ${I}$ in the domain of definition of ${f}$. What functions have finite ${NL(f)}$? Every Lipschitz function does, as was noted previously: ${NL(f) \le \frac14 \mathrm{Lip}\,(f)}$. But the converse is not true: for example, ${NL(f)}$ is finite for the non-Lipschitz function ${f(x)=x\log|x|}$, where ${f(0)=0}$.

The function looks nice, but ${f(x)/x}$ is clearly unbounded. What makes ${NL(f)}$ finite? Note the scale-invariant feature of NL: for any ${t>0}$ the scaled function ${f_t(x) = t^{-1}f(tx)}$ satisfies ${NL(f_t)=NL(f)}$, and more precisely ${NL(f; tI) = NL(f_t; I)}$. On the other hand, our function has a curious scaling property ${f_t(x) = f(x) + x\log t}$ where the linear term ${x\log t}$ does not affect NL at all. This means that it suffices to bound ${NL(f; I)}$ for intervals ${I}$ of unit length. The plot of ${f}$ shows that not much deviation from the secant line happens on such intervals, so I will not bother with estimates.

The class of functions ${f}$ with ${NL(f)<\infty}$ is precisely the Zygmund class ${\Lambda^*}$ defined by the property ${|f(x-h)-2f(x)+f(x+h)| \le Mh}$ with ${M}$ independent of ${x, h}$. Indeed, since the second-order difference ${f(x-h)-2f(x)+f(x+h)}$ is unchanged by adding an affine function to ${f}$, we can replace ${f}$ by ${f(x)-kx-r}$ with suitable ${k, r}$ and use the triangle inequality to obtain

${\displaystyle |f(x-h)-2f(x)+f(x+h)| \le 4 \sup_I |f(x)-kx-r| = 8h\; NL(f; I)}$

where ${I=[x-h, x+h]}$. Conversely, suppose that ${f\in \Lambda^*}$. Given an interval ${I=[a, b]}$, subtract an affine function from ${f}$ to ensure ${f(a)=f(b)=0}$. We may assume ${|f|}$ attains its maximum on ${I}$ at a point ${\xi \le (a + b)/2}$. Applying the definition of ${\Lambda^*}$ with ${x = \xi}$ and ${h = \xi - a}$, we get ${|f(2\xi - a) - 2f(\xi )| \le M h}$, hence ${|f(\xi )| \le Mh}$. This shows ${NL(f; I)\le M/2}$. The upshot is that ${NL(f)}$ is equivalent to the Zygmund seminorm of ${f}$ (i.e., the smallest possible M in the definition of ${\Lambda^*}$).

A function in ${\Lambda^*}$ may be nowhere differentiable: it is not difficult to construct ${f}$ so that ${NL(f;I)}$ is bounded between two positive constants. The situation is different for the small Zygmund class ${\lambda^*}$ whose definition requires that ${NL(f; I)\to 0}$ as ${|I|\to 0}$. A function ${f \in \lambda^*}$ is differentiable at any point of local extremum, since the condition ${NL(f; I)\to 0}$ forces its graph to be tangent to the horizontal line through the point of extremum. Given any two points ${a, b}$ we can subtract the secant line from ${f}$ and thus create a point of local extremum between ${a }$ and ${b}$. It follows that ${f}$ is differentiable on a dense set of points.

The definitions of ${\Lambda^* }$ and ${\lambda^*}$ apply equally well to complex-valued functions, or vector-valued functions. But there is a notable difference in the differentiability properties: a complex-valued function of class ${\lambda^*}$ may be nowhere differentiable [Ullrich, 1993]. Put another way, two real-valued functions in ${\lambda^*}$ need not have a common point of differentiability. This sort of thing does not often happen in analysis, where the existence of points of “good” behavior is usually based on the prevalence of such points in some sense, and therefore a finite collection of functions is expected to have common points of good behavior.

The key lemma in Ullrich’s paper provides a real-valued VMO function that has infinite limit at every point of a given ${F_\sigma}$ set ${E}$ of measure zero. Although this is a result of real analysis, the proof is complex-analytic in nature and involves a conformal mapping. It would be interesting to see a “real” proof of this lemma. Since the antiderivative of a VMO function belongs to ${\lambda^* }$, the lemma yields a   function ${v \in \lambda^*}$ that is not differentiable at any point of ${E}$. Consider the lacunary series ${u(t) = \sum_{n=1}^\infty a_n 2^{-n} \cos (2^n t)}$. One theorem of Zygmund shows that ${u \in \lambda^*}$ when ${a_n\to 0}$, while another shows that ${u}$ is almost nowhere differentiable when ${\sum a_n^2 = \infty}$. It remains to apply the lemma to get a function ${v\in \lambda^*}$ that is not differentiable at any point where ${u}$ is differentiable.

## Folded letters and uniformly bounded function sequences

We know that every bounded sequence of real numbers has a convergent subsequence. For a sequence of functions, say ${f_n\colon [0, 1]\to \mathbb R}$, the notion of boundedness can be stated as: there exists a constant ${M}$ such that ${|f_n(x)|\le M}$ for every ${n}$ and for all ${x\in [0, 1]}$. Such a sequence is called uniformly bounded.

Once we fix some point ${x\in [0, 1]}$, the boundedness assumption provides a subsequence ${\{f_{n_k}\}}$ which converges at that point. But since different points may require different subsequences, it is not obvious whether we can pick a subsequence ${\{f_{n_k}\}}$ which converges for all ${x\in [0, 1]}$. (Such a subsequence is called pointwise convergent.)

It is easy to give an example of a uniformly bounded sequence with no uniformly convergent subsequence (uniform convergence ${f_n\to f}$ requires ${\sup |f_n-f|\to 0}$, which is stronger than ${f_n(x) \to f(x)}$ for every ${x}$). Indeed, ${f_n(x) = x^n}$ does the job. This sequence is uniformly bounded (by ${M=1}$) and converges pointwise to a discontinuous function ${g}$ such that ${g(1)=1 }$ and ${g(x)=0}$ elsewhere. Any subsequence ${f_{n_k}}$ has the same pointwise limit ${g}$ and since ${g}$ is not continuous, the convergence cannot be uniform.

But what would be an example of a uniformly bounded sequence of continuous functions with no pointwise convergent subsequence? In Principles of Mathematical Analysis Rudin gives ${f_n(x) = \sin nx}$ as such an example but then uses the Lebesgue Dominated Convergence Theorem to prove the non-existence of pointwise convergent subsequences. I do not want to use the DCT.

The simplest example I could think of is based on the letter-folding function ${F\colon [0, 1]\to [0, 1]}$ defined by

${\displaystyle F(x) = \begin{cases} 3x, & x\in [0, 1/3] \\ 2 - 3x, & x\in [1/3, 2/3] \\ 3x - 2, & x \in [2/3, 1] \end{cases} }$

or by a magic one-line formula if you prefer: ${F(x) = 3x - 1 - |3x-1| + |3x - 2|}$.

Let ${\{f_n\}}$ be the sequence of the iterates of ${L}$, that is ${f_0(x) = x}$ and ${f_{n+1}(x) = F(f_n(x))}$. This means ${f_1 = F}$, ${f_2 = F\circ F}$, ${f_3 = F\circ F \circ F}$, and so on.

By construction, the sequence ${\{f_n\}}$ is uniformly bounded (${M=1}$). It is somewhat similar to the example ${\{\sin nx\}}$ in that we have increasingly rapid oscillations. But the proof that ${\{f_n\}}$ has no pointwise convergent subsequence is elementary. It is based on the following observations.

(A) Suppose that ${\{a_j\}}$ is a sequence such that ${a_j\in \{0, 2\}}$ for each ${j \in \mathbb N}$. Then the number ${\displaystyle x = \sum_{j=1}^\infty \frac{a_j}{3^j}}$ satisfies ${x\in [0, 1/3]}$ if ${a_1=0}$ and ${x\in [2/3, 1]}$ if ${a_1 = 2}$.

The proof of (A) amounts to summing a geometric series. Incidentally, observe that ${a_1, a_2, \dots}$ are the digits of ${x}$ in base ${3}$.

(B) For ${x}$ as above we have ${\displaystyle F(x) = \sum_{j=1}^\infty \frac{a_{j+1}}{3^j}}$. In other words, ${F}$ shifts the ternary digits of ${x}$ to the left. As a consequence, ${f_n}$ shifts them to the left by ${n}$ places.

(C) Given any subsequence ${\{f_{n_k}\}}$, let ${a_j = 2}$ if ${j = n_{2k} + 1}$ for some ${k}$, and ${a_j=0}$ otherwise. By part (B), ${\displaystyle f_{n_k}(x) = \sum_{j=1}^\infty \frac{a_{j + n_k}}{3^j} }$ which means the first ternary digit of ${f_{n_k}(x)}$ is ${a_{n_k + 1}}$. By construction, this digit is ${2}$ when ${k}$ is even, and ${0}$ when ${k}$ is odd. By part (A) we have ${f_{n_k}(x) \ge 2/3}$ when ${k}$ is even, and ${f_{n_k}(x) \le 1/3}$ when ${k}$ is odd. Thus, ${\{f_{n_k}(x)\}}$ does not converge. This completes the proof.

## Remarks

The set of all points ${x}$ of the form considered in (A), (B), (C), i.e., those with all ternary digits ${0}$ or ${2}$, is precisely the standard Cantor set ${C}$.

The function ${F}$ magnifies each half of ${C}$ by the factor of ${3}$, and maps it onto ${C}$.

The important part of the formula for ${F}$ is that ${F(x) = 3x\bmod 1}$ when ${x\in C}$. The rest of it could be some other continuous extension to ${[0, 1]}$.

A similar example could be based on the tent map ${T(x) = 1 - |2x-1|}$, whose graph is shown below.

However, in case of the tent map it is more convenient to use the sequence of even iterates: ${T\circ T}$, ${T\circ T\circ T\circ T}$, and so on.

Indeed, since ${T(T(x)) = 4x \bmod 1}$ when ${x\in [0, 1/4]\cup [1/2, 3/4]}$, one can simply replace base ${3}$ with base ${4}$ in all of the above computations and arrive at the same conclusion, except the orbit of ${x}$ will now be jumping between the intervals ${[0, 1/4]}$ and ${[1/2, 3/4]}$.

The tent map is conjugate to the logistic map ${L(x) = 4x(1-x)}$, shown below. This conjugacy is ${L\circ \varphi = \varphi\circ T}$ where ${\varphi(x) = (1 - \cos \pi x)/2}$.

The conjugacy shows that the ${n}$th iterate ${L^{n}}$ is ${\varphi\circ T^n \circ \varphi^{-1}}$. Therefore, the sequence of the even iterates of ${L}$ has no pointwise convergent subsequence. This provides an example with smooth functions, even polynomials.

One could use the sequence of all iterates (not just the even ones) in the constructions based on ${T}$ and ${L}$, it just takes a bit of extra work that I prefer to avoid.

## Pi and Python: how 22/7 morphs into 355/113

This is a brief return to the topic of Irrational Sunflowers. The sunflower associated with a real number ${a}$ is the set of points with polar coordinates ${r=\sqrt{k}}$ and ${\theta = a(2\pi k)}$, ${k=1, 2, \dots, n}$. A sunflower reduces to ${n}$ equally spaced rays if and only if ${a}$ is a rational number written in lowest terms as ${m/n}$.

Here is the sunflower of ${a=\pi}$ of size ${n = 10000}$.

Seven rays emanate from the center because ${\pi \approx 22/7}$, then they become spirals, and spirals rearrange themselves into 113 rays because ${\pi \approx 355/113}$. Counting these rays is boring, so here is a way to do this automatically with Python (+NumPy as np):

a = np.pi
n = 5000
x = np.mod(a*np.arange(n, 2*n), 1)
np.sum(np.diff(np.sort(x)) > 1/n)

This code computes the polar angles of sunflower points indexed ${5000\le k<10000}$, sorts them and counts the relatively large gaps between the sorted values. These correspond to the gaps between sunflower rays, except that one of the gaps gets lost when the circle is cut and straightened onto the interval ${[0, 2\pi)}$. So the program output (112) means there are 113 rays.

Here is the same sunflower with the points alternatively colored red and blue.

The colors blur into purple when the rational approximation pattern is strong. But they are clearly seen in the transitional period from 22/7 approximation to 355/113.

1. How many points would we need to see the next rational approximation after 355/113?
2. What will that approximation be? Yes, 22/7 and 355/113 and among the convergent of the continued fraction of ${\pi}$. But so is 333/106 which I do not see in the sunflower. Are some convergents better than others?

Finally, the code I used to plot sunflowers.

import numpy as np
import matplotlib.pyplot as plt
a = np.pi
k = np.arange(10000)
r = np.sqrt(k)
t = a*2*np.pi*k
plt.axes().set_aspect('equal')
plt.plot(r*np.cos(t), r*np.sin(t), '.')
plt.show()

## Transcendental-free Riemann-Lebesgue lemma

Calculus books tend to introduce transcendental functions (trigonometric, exponential, logarithm) early. Analysis textbooks such as Principles of Mathematical Analysis by Rudin tend to introduce them later, because of how long it takes to develop enough of the theory of power series.

The Riemann-Lebesgue lemma involves either trigonometric or exponential functions. But the following version works with the “late transcendentals” approach.

## Transcendental-free Riemann-Lebesgue Lemma

TFRLL. Suppose that ${f\colon [a, b]\to \mathbb R}$ and ${g\colon \mathbb R\to \mathbb R}$ are continuously differentiable functions, and ${g}$ is bounded. Then ${\int_a^b f(x)g'(nx)\,dx \to 0}$ as ${n\to\infty}$.

The familiar form of the lemma is recovered by letting ${g(x) = \sin x}$ or ${g(x) = \cos x}$.

Proof. By the chain rule, ${g'(nx)}$ is the derivative of ${g(nx)/n}$. Integrate by parts:

${\displaystyle \int_a^b f(x)g'(nx)\,dx = \frac{f(b)g(nb)}{n} - \frac{f(a)g(na)}{n} - \int_a^b f'(x)\frac{g(nx)}{n}\,dx }$

By assumption, there exists a constant ${M}$ such that ${|g|\le M}$ everywhere. Hence ${\displaystyle \left| \frac{f(b)g(nb)}{n}\right| \le \frac{|f(b)| M}{n} }$, ${\displaystyle \left|\frac{f(a)g(na)}{n}\right| \le \frac{|f(a)| M}{n}}$, and ${\displaystyle \left|\int_a^b f'(x)\frac{g(nx)}{n}\,dx\right| \le \frac{M}{n} \int_a^b |f'(x)|\,dx}$. By the triangle inequality,

${\displaystyle \left|\int_a^b f(x)g'(nx)\,dx \right| \le \frac{M}{n}\left(|f(b)|+|f(a)| + \int_a^b |f'(x)|\,dx \right) \to 0 }$

completing the proof.

As a non-standard example, TFRLL applies to, say, ${g(x) = \sin (x^2) }$ for which ${g'(x) = 2x\cos (x^2)}$. The conclusion is that ${\displaystyle \int_a^b f(x) nx \cos (n^2 x^2) \,dx \to 0 }$, that is, ${\displaystyle \int_a^b xf(x) \cos (n^2 x^2) \,dx = o(1/n)}$ which seems somewhat interesting. When ${0\notin [a, b]}$, the factor of ${x}$ can be removed by applying the result to ${f(x)/x}$, leading to ${\displaystyle \int_a^b f(x) \cos (n^2 x^2) \,dx = o(1/n)}$.

## What if we tried less smoothness?

Later in Rudin’s book we encounter the Weierstrass theorem: every continuous function on ${[a, b]}$ is a uniform limit of polynomials. Normally, this would be used to make the Riemann-Lebesgue lemma work for any continuous function ${f}$. But the general form given above, with an unspecified ${g}$, presents a difficulty.

Indeed, suppose ${f}$ is continuous on ${[a, b]}$. Given ${\epsilon > 0 }$, choose a polynomial ${p}$ such that ${|p-f|\le \epsilon}$ on ${[a, b]}$. Since ${p}$ has continuous derivative, it follows that ${\int_a^b p(x)g'(nx)\,dx \to 0}$. It remains to show that ${\int_a^b p(x)g'(nx)\,dx}$ is close to ${\int_a^b f(x)g'(nx)\,dx}$. By the triangle inequality,

${\displaystyle \left| \int_a^b (p(x) - f(x))g'(nx)\,dx \right| \le \epsilon \int_a^b |g'(nx)|\,dx }$

which is bounded by … um. Unlike for ${\sin }$ and ${\cos}$, we do not have a uniform bound for ${|g'|}$ or for its integral. Indeed, with ${g(x) = \sin x^2}$ the integrals ${\displaystyle \int_0^1 |g'(nx)| \,dx = \int_0^1 2nx |\cos (n^2x^2)| \,dx }$ grow linearly with ${n}$. And this behavior would be even worse with ${g(x) = \sin e^x}$, for example.

At present I do not see a way to prove TFRLL for continuous ${f}$, let alone for integrable ${f}$. But I do not have a counterexample either.

## Partitions of unity and monotonicity-preserving approximation

There are many ways to approximate a given continuous function ${f\colon [a, b]\to \mathbb R}$ (I will consider the interval ${[a, b]=[0, 1]}$ for convenience.) For example, one can use piecewise linear interpolation through the points ${(k/n, f(k/n))}$, where ${k=0, 1, \dots, n}$. The resulting piecewise linear function ${g}$ has some nice properties: for example, it is increasing if ${f}$ is increasing. But it is not smooth.

A convenient way to represent piecewise linear interpolation is the sum ${g(x) = \sum_{k=0}^n f(k/n) \varphi_k(x)}$ where the functions ${\varphi_k}$ are the triangles shown below: ${\varphi_k(x) = \max(0, 1 - |nx-k|)}$.

The functions ${{\varphi_k}}$ form a partition of unity, meaning that ${\sum_k \varphi_k \equiv 1}$ and all ${\varphi_k}$ are nonnegative. This property leads to the estimate

${\displaystyle |f(x) - g(x)| = \left| \sum_{k=0}^n (f(x) - f(k/n)) \varphi_k(x)\right| \le \sum_{k=0}^n |f(x) - f(k/n)| \varphi_k(x) }$

The latter sum is small because when ${x}$ is close to ${k/n}$, the first factor ${|f(x) - f(k/n)|}$ is small by virtue of continuity, while the second factor ${\varphi_k(x)}$ is bounded by ${1}$. When ${x}$ is far from ${k/n}$, the second factor ${\varphi_k(x)}$ is zero, so the first one is irrelevant. The upshot is that ${f-g}$ is uniformly small.

But if we want a smooth approximation ${g}$, we need a smooth partition of unity ${{\varphi_k}}$. But not just any set of smooth nonnegative functions that add up to ${0}$ is equally good. One desirable property is preserving monotonicity: if ${f}$ is increasing, then ${g}$ should be increasing, just as this works for piecewise linear interpolation. What does this condition require of our partition of unity?

An increasing function can be expressed as a limit of sums of the form ${\sum_{j} c_j [x \ge t_j]}$ where ${c_j>0}$ and ${[\cdots ]}$ is the Iverson bracket: 1 if true, 0 if false. By linearity, it suffices to have increasing ${g}$ for the case ${f(x) = [x \ge t]}$. In this case ${g}$ is simply ${s_m := \sum_{k=m}^n \varphi_k}$ for some ${m}$, ${0\le m\le n}$. So we want all ${s_m}$ to be increasing functions. Which is the case for the triangular partition of unity, when each ${s_m}$ looks like this:

One smooth choice is Bernstein basis polynomials: ${\displaystyle \varphi_k(x) = \binom{n}{k} x^k (1-x)^{n-k}}$. These are nonnegative on ${[0, 1]}$, and the binomial formula shows ${\displaystyle \sum_{k=0}^n \varphi_k(x) = (x + 1-x)^n \equiv 1}$. Are the sums ${\displaystyle s_m(x) = \sum_{k=m}^n \binom{n}{k} x^k (1-x)^{n-k}}$ increasing with ${x}$? Let’s find out. By the product rule,

${\displaystyle s_m'(x) = \sum_{k=m}^n \binom{n}{k} k x^{k-1} (1-x)^{n-k} - \sum_{k=m}^n \binom{n}{k} (n-k) x^{k} (1-x)^{n-k - 1}}$

In the second sum the term with ${k=n}$ vanishes, and the terms with ${k can be rewritten as ${\displaystyle \frac{n!}{k! (n-k)!} (n-k) x^{k} (1-x)^{n-k - 1}}$, which is ${\frac{n!}{(k+1)! (n-k-1)!} (k+1) x^{k} (1-x)^{n-k - 1}}$, which is ${\binom{n}{k+1} (k+1) x^{k} (1-x)^{n-k - 1} }$. After the index shift ${k+1\mapsto k}$ this becomes identical to the terms of the first sum and cancels them out (except for the first one). Thus,

${\displaystyle s_m'(x) = \binom{n}{m} m x^{m-1} (1-x)^{n-m} \ge 0 }$

To summarize: the Bernstein polynomials ${\displaystyle B_n(x) = \sum_{k=0}^n f(k/n) \binom{n}{k} x^k (1-x)^{n-k}}$ are monotone whenever ${f}$ is. On the other hand, the proof that ${B_n\to f}$ uniformly is somewhat complicated by the fact that the polynomial basis functions ${\varphi_k}$ are not localized the way that the triangle basis functions are: the factors ${\varphi_k(x)}$ do not vanish when ${x}$ is far from ${k/n}$. I refer to Wikipedia for a proof of convergence (which, by the way, is quite slow).

Is there some middle ground between non-smooth triangles and non-localized polynomials? Yes, of course: piecewise polynomials, splines. More specifically, B-splines which can be defined as follows: B-splines of degree ${1}$ are the triangle basis functions shown above; a B-spline of degree ${d+1}$ is the moving averages of a ${B}$-spline of degree ${d}$ with a window of length ${h = 1/n}$. The moving average of ${F}$ can be written as ${\frac{1}{h} \int_{x-h/2}^{x+h/2} f}$. We get a partition of unity because the sum of moving averages is the moving average of a sum, and averaging a constant function does not change it.

The splines of even degrees are awkward to work with… they are obtained from the triangles by taking those integrals with ${h/2}$ an odd number of times, which makes their knots fall in the midpoints of the uniform grid instead of the grid points themselves. But I will use ${d=2}$ anyway, because this degree is enough for ${C^1}$-smooth approximation.

Recall that a triangular basis function ${\varphi_k}$ has slope ${\pm n}$ and is supported on an interval ${[(k-1)h, (k+1)h]}$ where ${h=1/n}$. Accordingly, its moving average ${\psi_k}$ will be supported on ${[(k-3/2)h, (k+3/2)h]}$. Since ${\psi_k'(x) = n(\phi_k(x+h/2) - \phi_k(x-h/2))}$, the second derivative ${\psi_k''}$ is ${n^2}$ when ${-3/2< nx-k< -1/2}$, is ${-2n^2}$ when ${|nx-k| < 1/2}$, and is ${n^2}$ again when ${1/2 < nx-k < 3/2}$. This is enough to figure out the formula for ${\psi_k}$:

${\displaystyle \psi_k(n) = \begin{cases} (nx-k+3/2)^2 / 2, & -3/2\le nx -k\le -1/2 \\ 3/4 -(nx-k)^2, & -1/2\le nx-k \le 1/2 \\ (nx-k-3/2)^2 / 2, & 1/2\le nx -k \le 3/2 \\ \end{cases} }$

These look like:

Nice! But wait a moment, the sum near the endpoints is not constant: it is less than 1 because we do not get a contributions of two splines to the left and right of the interval. To correct for this boundary effect, replace ${\psi_0}$ with ${\psi_0 + \psi_{-1}}$ and ${\psi_n}$ with ${\psi_n + \psi_{n+1}}$, using “ghost” elements of the basis that lie outside of the actual grid. Now the quadratic B-spline basis is correct:

Does this partition of unity preserve monotinicity? Yes, it does: ${\displaystyle \sum_{k\ge m}\psi_k'(x) = n\sum_{k\ge m} (\phi_k(x+h/2) - \phi_k(x-h/2)) = n(s(x+h/2) - s(x-h/2))}$ which is nonnegative because the sum ${s := \sum_{k\ge m} \phi_k}$ is an increasing piecewise linear function, as noted previously. Same logic works for B-splines of higher degree.

In conclusion, here is a quadratic B-spline approximation (orange) to a tricky increasing function (blue).

One may wonder why the orange curve deviates from the line at the end – did we miss some boundary effect there? Yes, in a way… the spline actually approximates the continuous extension of our original function by constant values on the left and right. Imagine the blue graph continuing to the right as a horizontal line: this creates a corner at ${x=1}$ and the spline is smoothing that corner. To avoid this effect, one may want to extend ${f}$ in a better way and then work with the extended function, not folding the ghosts ${\psi_{-1}, \psi_{n+1}}$ into ${\psi_0, \psi_n}$.

But even so, B-spline achieves a better approximation than the Bernstein polynomial with the same number of basis functions (eight):

The reason is the non-local nature of the polynomial basis ${\varphi_k}$, which was noted above. Bernstein polynomials do match the function perfectly at the endpoints, but this is small consolation.

## The closure of periodic functions and sums of waves with incommensurable periods

Consider the space ${C(\mathbb R)}$ of all bounded continuous functions ${f\colon \mathbb R\to\mathbb R}$, with the uniform norm ${\|f\| = \sup |f|}$. Let ${P}$ be its subset that consists of all periodic continuous functions: recall that ${f}$ is periodic if there exists ${T>0}$ such that ${f(x+T)=f(x)}$ for all ${x\in \mathbb R}$.

The set ${P}$ is not closed in the topology of ${C(\mathbb R)}$. Indeed, let ${d(x) = \mathrm{dist}\,(x, \mathbb Z)}$ be the distance from ${x}$ to nearest integer. The function ${d}$ is periodic with ${T=1}$. Therefore, each sum of the form ${\displaystyle \sum_{k=0}^n 2^{-k} d(2^{-k} x)}$ is periodic with ${T=2^n}$. Hence the sum of the infinite series ${\displaystyle f(x) = \sum_{k=0}^\infty 2^{-k} d(2^{-k} x) }$ is a uniform limit of periodic functions. Yet, ${f}$ is not periodic, because ${f(0)=0}$ and ${f(x)>0 }$ for ${x\ne 0}$ (for every ${x\ne 0}$ there exists ${k}$ such that ${2^{-k}x}$ is not an integer).

The above example (which was suggested to me by Yantao Wu) is somewhat similar to the Takagi function, which differs from it by the minus sign in the exponent: ${\displaystyle T(x) = \sum_{k=0}^\infty 2^{-k} d(2^{k} x) }$. Of course, the Takagi function is periodic with period ${1}$.

Do we really need an infinite series to get such an example? In other words, does the set ${\overline{P}\setminus P}$ contain an elementary function?

A natural candidate is the sum of trigonometric waves with incommensurable periods (that is, the ratio of periods must be irrational). For example, consider the function ${g(x) = \cos (x) + \cos (\sqrt{2}x)}$ whose graph is shown below.

Since ${g(0)=2}$ and ${g(x) < 2}$ for all ${x\ne 0}$, the function ${g}$ is not periodic. Its graph looks vaguely similar to the graph of ${f}$. Is ${g}$ a uniform limit of periodic functions?

Suppose ${h\colon \mathbb R\to\mathbb R}$ is a ${T}$-periodic function such that ${\|h-g\|<\epsilon}$. Then ${h(0) > 2-\epsilon}$, hence ${h(nT)>2-\epsilon}$ for all ${n\in \mathbb Z}$, hence ${g(nT) > 2- 2\epsilon }$. By the definition of ${g}$ this implies ${\cos (nT) > 1-2\epsilon}$ and ${\cos (\sqrt{2}nT) > 1-2\epsilon}$ for all ${n\in \mathbb Z}$. The following lemma shows a contradiction between these properties.

Lemma. If a real number ${t}$ satisfies ${\cos nt > -1/2}$ for all ${n\in \mathbb Z}$, then ${t}$ is an integer multiple of ${2\pi}$.

Proof. Suppose ${t}$ is not an integer multiple of ${2\pi}$. We can assume ${0 < t < \pi}$ without loss of generality, because ${t}$ can be replaced by ${t - 2\pi k}$ to get it in the interval ${(0, 2\pi)}$ and then by ${2\pi - t}$ to get it in ${(0, \pi)}$. Since ${\cos t > -1/2}$, we have ${t\in (0, 2\pi/3)}$. Let ${k}$ be the smallest positive integer such that ${2^k t \ge 2\pi/3}$. The minimality of ${k}$ implies ${2^{k-1} t < 2\pi/3}$, hence ${2^k t \in [2\pi/3, 4\pi/3)}$. But then ${\cos (2^k t) \le -1/2}$, a contradiction. ${\quad \Box}$

The constant ${-1/2}$ in the lemma is best possible, since ${\cos (2n\pi/3)\ge -1/2}$ for all ${n\in \mathbb Z}$.

Returning to the paragraph before the lemma, choose ${\epsilon=3/4}$ so that ${1-2\epsilon = -1/2}$. The lemma says that both ${T}$ and ${\sqrt{2} T}$ must be integer multiples of ${2\pi}$, which is impossible since they are incommensurable. This contradiction shows that ${\|g-h\|\ge 3/4}$ for any periodic function ${h}$, hence ${g}$ is not a uniform limit of periodic functions.

The above result can be stated as ${\mathrm{dist}(g, P) \ge 3/4}$. I guess ${\mathrm{dist}(g, P)}$ is actually ${1}$. It cannot be greater than ${1}$ since ${|g(x)-\cos x|\le 1}$ for all ${x}$. (Update: Yantao pointed out that the density of irrational rotations implies the distance is indeed equal to 1.)

Note: the set ${\overline{P}}$ is a proper subset of the set of (Bohr / Bochner / uniform) almost periodic functions (as Yemon Choi pointed out in a comment). The latter is a linear space while ${\overline{P}}$ is not. I was confused by the sentence “Bohr defined the uniformly almost-periodic functions as the closure of the trigonometric polynomials with respect to the uniform norm” on Wikipedia. To me, a trigonometric polynomial is a periodic function of particular kind. What Bohr called Exponentialpolynom is a finite sum of the form ${\sum a_n e^{\lambda_n x}}$ where ${\lambda_n}$ can be any real numbers. To summarize: the set considered above is the closure of ${P}$ while the set of almost periodic functions is the closed linear span of ${P}$. The function ${g(x)=\cos (x) + \cos(\sqrt{2} x)}$ is an example of the latter, not of the former.

## Points of maximal curvature

In Calculus I students are taught how to find the points at which the graph of a function has zero curvature (that is, the points of inflection). The points of maximal curvature are usually not discussed. This post attempts to rectify this omission.

The (signed) curvature of ${y=f(x)}$ is

${\displaystyle \kappa = \frac{y''}{(1+(y')^2)^{3/2}}}$

We want to maximize the absolute value of ${\kappa}$, whether the function is positive or negative there (so both maxima and minima of ${\kappa}$ can be of interest). The critical points of ${\kappa}$ are the zeros of

${\displaystyle \kappa' = \frac{y''' (1+(y')^2) - 3 y' (y'')^2 }{(1+(y')^2)^{5/2}}}$

So we are lead to consider a polynomial of the first three derivatives of ${y}$, namely ${p := y''' (1+(y')^2) - 3 y' (y'')^2 }$.

Begin with some simple examples:

${y = x^2}$ has ${p = -24x}$ so the curvature of a parabola is maximal at its vertex. No surprise there.

${y = x^3}$ has ${p = 6(1 - 45x^4)}$, indicating two symmetric points of maximal curvature, ${x\approx \pm 0.386}$, pretty close to the point of inflection.

${y=x^4}$ has ${p = 24 x (1 - 56 x^6)}$. This has three real roots, but ${x=0}$ actually minimizes curvature (it vanishes there).

More generally, ${y=x^n}$ with positive integer ${n}$ yields ${\displaystyle p = n(n-1)x^{n-3} (n - 2 - (2n^3-n^2) x^{2n-2})}$ indicating two points ${\displaystyle x = \pm \left(\frac{n-2}{2n^3-n^2} \right)^{1/(2n-2)}}$ which tend to ${\pm 1}$ as ${n}$ grows.

The graph of a polynomial of degree ${n}$ can have at most ${n-2}$ points of zero curvature, because the second derivative vanishes at those. How many points of maximal curvature can it have? The degree of expression ${p}$ above is ${3n-5}$ but it is not obvious whether all of its roots can be real and distinct, and also be the maxima of ${|\kappa|}$ (unlike ${x=0}$ for ${y=x^4}$). For ${n=2}$ we do get ${3n-5 = 1}$ point of maximal curvature. But for ${n=3}$, there can be at most ${2}$ such points, not ${3n-5 = 4}$. Edwards and Gordon (Extreme curvature of polynomials, 2004) conjectured that the graph of a polynomial of degree ${n}$ has at most ${n-1}$ points of maximal curvature. This remains open despite several partial results: see the recent paper Extreme curvature of polynomials and level sets (2017).

A few more elementary functions:

${y = e^x}$ has ${p = e^x(1-2e^{2x})}$, so the curvature is maximal at ${x=-\log(2)/2}$. Did I expect the maximum of curvature to occur for a negative ${x}$? Not really.

${y=\sin x}$ has ${p = (\cos 2x - 3)\cos x}$. The first factor is irrelevant: the points of maximum curvature of a sine wave are at its extrema, as one would guess.

${y = \tan x}$ has ${p = -6\tan^8(x) - 16\tan^6(x) - 6\tan^4(x) + 8\tan(x)^2 + 4}$ which is zero at… ahem. The expression factors as

${\displaystyle p = -2(\tan^2 x+1)(3\tan^6(x) + 5\tan^4(x) - 2\tan^2(x) - 2)}$

Writing ${u = \tan^2(x)}$ we can get a cubic equation in ${u}$, but it is not a nice one. Or we could do some trigonometry and reduce ${p=0}$ to the equation ${8 - 41\cos 2x + \cos 6x =0}$. Either way, a numerical solution is called for: ${x \approx \pm 0.6937}$ (and ${+\pi n}$ for other periods).