Keeping the first J cosine terms of r leaves the bias BJ = Σj > J θj². How fast it falls depends on smoothness and on the end points: the cosine series is the Fourier series of r reflected about 0 and 1, so a function whose slope is not zero at the ends gets a kink there, coefficients of order j−2 and BJ of order J−3, however smooth it is inside. The series estimator is also a kernel smoother: its weights are a Dirichlet kernel plus a mirror image, which doubles the weight at the boundary.
The coefficients θj = ∫01 r φj are computed by the midpoint rule on 20,000 points, and BJ = ∫r² − Σj ≤ J θj² (Parseval). The kernel is nℓi(x) = Σj ≤ J φj(x)φj(xi) of (8.11) for n = 1000 points xi = i/n, with the closed form D(x − y) + D(x + y), D(t) = sin((J − ½)πt)/(2 sin(πt/2)) dashed.
code/ch08_orthogonal_functions.py (cos_basis, exact_coefficients, weights_grid, fig_8_S1).