1

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

amWhy
  • 209,954

1 Answers1

0

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$.

clathratus
  • 17,161
  • Thank you so much, that's it; it becomes $\frac 1\pi \int \cos^2(x)$, which is 1 in the considered interval! I don't understand, why does the formula $a_k(f(x))=\frac 1\pi \int_{-\pi}^\pi (x+\cos(x)) \cos(kx) dx$, with an unspecified k, not account for that result? When I computed it on paper I got a straight zero, and integral-calculator.com gives $-\frac {2k\sin(\pi k)}{\pi (k^2-1)}$, which is zero for every k natural. Am I missing some necessary condition to use said formula? – ducksattack Aug 25 '21 at 18:26
  • 1
    Wait I see it... with $k=1$ I get a zero in the denominator, so the formula is no good there and I should have checked that k directly! Thank you again, my sanity has been restored – ducksattack Aug 25 '21 at 18:29
  • I wish I could vote your answer as useful but I don't have 15 rep... – ducksattack Aug 25 '21 at 18:30
  • @ducksattack I'm glad you found my answer useful :) – clathratus Aug 26 '21 at 20:37