Solution (source code)

= Solution

Use the usual localized, <compact support> construction of an <interval-adapted wavelet basis>, including <boundary wavelets> with the stated <vanishing moments>, and order the <linear N-term approximation> by increasing resolution. Also interpret a <piecewise polynomial function> as having finitely many pieces. These conventions matter: regularity and <vanishing moments> alone, or an arbitrary enumeration, do not establish the asserted rates.

At scale $j$, a <wavelet> whose support lies in one polynomial piece has zero coefficient because $p<q$. Only a bounded number $B$ of <wavelets> per scale can meet a partition point. Their $L^1$ <norms> are bounded by $C2^{-j/2}$, and $f$ is bounded. Thus $|c_{j,k}|\le C_f2^{-j/2}$ and
$$
\sum_k|c_{j,k}|^2\le C_f'2^{-j}.
$$
Retain the fixed number of coarse <scaling function> coefficients and every nonzero coefficient through level $J$. This uses at most $B(J+1)+B_0$ terms, leaving squared error at most $C2^{-J}$. The optimal <best N-term approximation> is no worse; choose $J$ proportional to $N$ to obtain $O(\omega^N)$ for some $\omega\in(0,1)$. In contrast, retaining all <wavelets> through level $J$ costs $\asymp2^J$ terms. Choosing the last complete level before $N$ gives
$$
\boxed{\|f-f_N^n\|_2^2=O(\omega^N),\qquad \|f-f_N^l\|_2^2=O(N^{-1}).}
$$
These are squared errors; the corresponding $L^2$ errors are $O(\omega^{N/2})$ and $O(N^{-1/2})$.