0
$\begingroup$

As I understand it:

$\cos^2(t)$ is even because it is a product of two even functions $\cos(t)$.

The Fourier series and Fourier cosine series of an even function is the same link.

So in the fourier series expansion $\cos^2(t)={a_0 \over 2}+\sum_{n=1}^\infty(a_n\cos(n \omega t) + b_n \sin(n \omega t))$, I expect $a_n\neq 0$ and $b_n=0$.

I try to get the the coefficients with wolfram alpha like this:

$a_n$ with FourierCosCoefficient[$\cos(t)^2,t,n$] gives zero link

$b_n$ with FourierSinCoefficient[$\cos(t)^2,t,n$] gives non-zero link

Which of my assumptions are wrong?

(I also got $a_n=0$ when calculating by hand so the question is not primarily about wolfram alpha but about the relation between Fourier series, Fourier cosine series, and even functions)

$\endgroup$
  • $\begingroup$ Looks to me that already $a_0 = \frac{1}{2} \ne 0$... Can you detail your computations ? $\endgroup$ – Gâteau-Gallois Mar 9 at 11:30
  • 1
    $\begingroup$ I'm not familiar enough with WolframAlpha to say, but it seems to me this is likely to be a misunderstanding of what the function does. For example, where's the $\omega$ in that call? Maybe it's trying to project the function on a different period? As it stands, $cos^2(t) = 1/2+1/2cos(2t)$, so that's all your Fourier series. $\endgroup$ – Okarin Mar 9 at 11:41
  • $\begingroup$ The correct answer is $a_0=a_2=\frac 1 2$ and all other coefficients $0$. $\endgroup$ – Kabo Murphy Mar 9 at 11:41
  • $\begingroup$ Surprisingly Mathematica gives the same answer. OTOH to the integral FourierCosCoefficient[(1+Cos[2t])/2,t,n]it gives the expected (DiscreteDelta[n-2]+2 DiscreteDelta[n])/2 $\endgroup$ – Jyrki Lahtonen Mar 9 at 11:50
  • 1
    $\begingroup$ FWIW, I asked this at Mathematica.SE. $\endgroup$ – Jyrki Lahtonen Mar 9 at 12:06
3
$\begingroup$

Just read the documentation: https://reference.wolfram.com/language/ref/FourierSinCoefficient.html

The command FourierSinCoefficient does not compute the coefficients $b_n$ in the full Fourier series, but the coefficients in the Fourier sine series (= the full Fourier series of the odd extension of the function in question).

$\endgroup$
  • $\begingroup$ Thanks, this shows why I was wrong to assume I could calculate $b_n$ with FourierSinCoefficient. I still think I should be able to calculate $a_n$ with FourierCosCoefficient. $\endgroup$ – aardvark Mar 9 at 14:05
1
$\begingroup$

The simplest way to find the Fourier series of this function is to write it as $\frac {1+\cos(2t)} 2$. This expression is in fact the Fourier series!.

$\endgroup$
  • 2
    $\begingroup$ I'm sure we all know this. The question is why WolframAlpha gives a different answer. $\endgroup$ – Jyrki Lahtonen Mar 9 at 11:46
0
$\begingroup$

It is clear that, for each $n\in\mathbb N$,$$\int_{-\pi}^\pi\cos^2(t)\sin(nt)\,\mathrm dt=0,$$since $t\mapsto\cos^2(t)\sin(nt)$ is an odd function.

On the other hand,$$a_0=\frac1\pi\int_{-\pi}^\pi\cos^2(t)\,\mathrm dt=1\neq0.$$It turns out that $a_1=0$, but $a_2=\frac12\neq0$.

$\endgroup$
  • $\begingroup$ I'm sure we all know this. The question is why WolframAlpha gives a different answer. $\endgroup$ – Jyrki Lahtonen Mar 9 at 11:48
  • 1
    $\begingroup$ No, we don't all know this, since the OP claimed to have obtained $a_n=0$ while calculating by hand. $\endgroup$ – José Carlos Santos Mar 9 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.