Solution
= Solution
For $\beta^2=1$, the reduced equation is $u''+u=1+\cos x$. The constant forcing has particular solution one, while the resonant cosine requires $u_p=(x/2)\sin x$. Thus
$$
\boxed{y=e^x\left[A\cos x+B\sin x+1+\frac x2\sin x\right],\qquad\beta=\pm1.}
$$
The secular factor $x$ is the signature of <resonance>. It must replace the divergent nonresonant coefficient $1/(\beta^2-1)$; substituting $\beta^2=1$ directly into that coefficient is invalid.