Sorry for the horrible formatting, this is the first time I use MathJax…
When I try to compute the Fourier series for $f(x)=x+\cos(x)$ directly I get the Fourier series for $f(x)=x$ instead, what am I missing? Please help restore my sanity.
Being $f(x)=x+\cos(x)$ the sum of two functions, its Fourier series is simply the sum of the Fourier series for $g(x)=x$, which is
$Sg(x)=-2\sum_{k=1}^\infty \frac {(-1)^k}k \sin(kx)$
and for $h(x)=\cos x$, which is trivially
$Sh(x)=\cos(x)$ itself.
As an exercise, I tried to compute $f$'s Fourier series directly, calculating its real coefficients with the usual formulas
$a_k(f(x))=\frac 2T \int_{T} f(x)\cos(\omega k x)dx$, for $k\ge0$
$b_k(f(x))=\frac 2T \int_{T} f(x)\sin(\omega k x)dx $, for $k\ge 1$.
In this case, $f(x)=x+\cos(x)$, $T=2\pi$, $\frac 2T=\frac 1\pi$, $\omega=\frac {2\pi}T=1$, so I get
$a_k(f(x))=\frac 1\pi \int_{-\pi}^\pi (x+\cos(x))\cos( k x)dx$
$b_k(f(x))=\frac 1\pi \int_{-\pi}^\pi (x+\cos(x))\sin( k x)dx$
I tried to compute these a bunch of times both on paper by myself and with integral-calculator.com, and what I get is always the same: $a_k(f(x))=0$ for every natural number $k\ge0$ (you get a sine with $(\pi k)$ as argument), and
$b_k(f(x))=-\frac 2k (-1)^k$.
But then $f$'s Fourier series in $[-\pi, \pi]$, obtained via
$Sf(x)=\frac {a_0}2+\sum_{k=1}^\infty[a_k \cos(k x)+b_k \sin (kx)] $,
is equal to $Sg(x)$, the series for $g(x)=x$… it's missing a $+\cos(x)$ to be the correct result for $f(x)=x+\cos(x)$
There must be something utterly dumb that I am missing, either conceptually or in the steps I am doing in practice, please help me see what it is
Best Answer
You seem to have missed the coefficient
$$a_1=\frac1\pi\int_{-\pi}^{\pi}(x+\cos(x))\cos(x)dx=1.$$ This should make up for your missing $\cos x$.