How are Fourier coefficients calculated using the trapezoidal rule?

659 Views Asked by At

The analytic definition of the Fourier coefficient $a_k$ is given by:

$$a_k = \frac{1}{\pi} \int_{0}^{2\pi} f(t) \cos(kt) \ dt \tag 1$$

I'm struggling to understand how the Fourier coefficients are calculated using trapezoidal integration method. Applying the method to $(1)$ gives

$$ a_k = \frac{2 \pi}{n} \cdot \frac{1}{\pi} \cdot \left(\frac{f(0) + f(2 \pi)}{2} \right) + \sum \limits_{j = 1}^{n-1} \cos \left(k \cdot \frac{2\pi j}{n} \right) \cdot f \left(\frac{2\pi j}{n} \right)$$

where

\begin{align} x_j &= \frac{2\pi j}{n} \\\\ y_j &= \begin{cases} f(x_j)&\text{if}\, 1 \leq j \leq n-1 \\\\ \dfrac{f(0)+f(2\pi)}{2} & \text{if } j=0 \\ \end{cases} \end{align}

because of $$ k x_j = w \cdot \frac{2\pi j}{n} = j \cdot x_k$$

$$a_w = \frac{2}{n} \cdot \left(y_0 + \sum \limits_{j = 1}^{n-1} \cos(jx_k) \cdot y_j \right) $$

The last two lines give me headaches. What is the purpose of the second last line. And how can I calculate $a_w$ when there is no w in the last line? Unfortunately I'm not even sure if it is correct since I have a hard time deciphering the handwritten lecture notes by my professor.


EDIT: In the second last line. Since $ x_j = \frac{2\pi j}{n}$ it follows that $ k = w$. Then $x_k = x_j$ and $w=j$?


EDIT 2: Assuming that the considerations of my first edit are true, it would allow us to write the last sum as only dependent on $j$ since $x_j = x_k = \frac{2\pi j}{n}$ This would allow us to calculate $x_w = x_k$ by using the last sum.

A picture of the result so far. Blue line is original function. Orange line is approximation

Result preliminary

1

There are 1 best solutions below

2
On BEST ANSWER

Expanding the last line a bit, assuming that what appeared to you as "$w$" is just a poorly-written $k$ (you did say it was hand-written and you were having trouble deciphering the handwriting), we have

$$ k x_j = k \cdot \frac{2\pi j}{n} = jk \cdot \frac{2\pi}{n} = j \cdot \frac{2\pi k}{n} = j \cdot x_k. $$

Nowhere is it trying to imply that $k = j$ or $x_k = x_j.$ It's just using the facts that multiplication is associative and commutative (with division defined as multiplication by the multiplicative inverse).

The purpose of the step is a little unclear. I suppose it saves a few multiplications when you do each sum as an independent calculation with no precomputation (as opposed to calculating all possible $x_j$ terms first and recording them somewhere where you can easily retrieve them during the integration).