Solution (source code)

= Solution

As printed in the original PDF, this claim is false for $n\geq2$. The displayed frequency is one, so the function already belongs to the space of <trigonometric polynomials> of degree at most $n-1$. Its best approximation is then the function itself, with zero error; for example, $\alpha=1,\beta=0$ gives a zero-approximant error $\int_0^{2\pi}|\cos x|\,dx=4$ instead. For $n=1$, zero is indeed the best constant approximation. Thus the literal answer is
$$
\boxed{p_*=f\quad(n\geq2),\qquad p_*=0\quad(n=1).}
$$

The natural intended version has frequency $n$. Set $g(y)=\alpha\cos y+\beta\sin y$ and $f_n(x)=g(nx)$. The sign function $h(y)=\operatorname{sign}g(y)$ is integrable and satisfies $h(y+\pi)=-h(y)$, so its <mean> is zero. Part (b) makes $h(nx)=\operatorname{sign}f_n(x)$ orthogonal to every degree-at-most-$n-1$ <trigonometric polynomial>. Part (a), with $p_*=0$, now proves
$$
\boxed{\text{The best approximation to }\alpha\cos(nx)+\beta\sin(nx)
\text{ from }\mathcal T_{n-1}\text{ in }L^1\text{ is }0.}
$$
The error is $4\sqrt{\alpha^2+\beta^2}$ for the unnormalized integral over a period.

The best approximant is unique. If the amplitude is nonzero and another continuous <trigonometric polynomial> $p$ has the same optimal error, equality in part (a)'s pointwise inequality holds almost everywhere. Near each zero of $f_n$, the function changes sign; if $p$ did not vanish at that zero, continuity would force an interval on one side where $f_n-p$ has the wrong sign, making the integral inequality strict. Thus $p$ vanishes at all $2n$ distinct zeros of $f_n$. A nonzero <trigonometric polynomial> of degree at most $n-1$ has at most $2n-2$ zeros in one period, since multiplication by $e^{i(n-1)x}$ turns it into a <polynomial> in $e^{ix}$ of degree at most $2n-2$. Hence $p=0$. Zero amplitude is immediate. The same reasoning proves the literal frequency-one assertion when $n=1$, while retaining the counterexample for larger $n$.