0

I'm having a bit of trouble completing a homework question of mine. I am supposed to expand an equation using Fourier and then graph said equation using Matlab. And no matter what I do the graph of the original equation and the Fourier equation never match up at all.

The question given is:

Given $f(x)= \begin{cases} L/2, & 0 \le x \le L/2 \\ x - L/2, & L/2 \lt x \le L \end{cases}$

expand $f(x)$ in terms of the functions $\{1, \cos(\frac{n{\pi}x}{L})\}, \; n \in \mathbb{Z^+}, \; \text{on } 0 \le x \le L$.

By the looks of it, it wants me to turn it into an even function and to only calculate $a_0$ and $a_n$.

If I do this the fourier series ends up being the following:

$$F(x)= \frac{3L}{8}+ \frac{2L}{\pi^2}\sum_{n=1}^\infty \frac{1}{n^2}[1-(-1)^{n+1}]\cos(\frac{n{\pi}x}{L})$$

If I put that into Matlab and graph it, it will come out as this: f(x) vs F(x). The blue line is the original equation, while the red line is the Fourier expansion. Here is the Matlab code I'm using. As you can see these are nothing alike.

Can someone smarter than me try to pinpoint my mistake and help me understand?

  • How many terms of the Fourier expansion are you using? – Julián Aguirre Mar 20 '17 at 15:02
  • @JuliánAguirre Apparently, at least 100, since the plot doesn't look like an analytic even function, despite being created from cosines. @ Bradley, please show how you derive your $F$. It doesn't look correct. – Ruslan Mar 20 '17 at 17:55
  • Here is my working: Page 1, Page 2.

    For the number of terms of the Fourier expansion, I just used whatever amount I set in Matlab (started with 100). No matter how many I did it never looked like what the actual solution is.

    – Bradley Gray Mar 20 '17 at 21:58
  • The cosine terms all have $0$ endpoint derivatives, which is also true of any finite sum of such terms. That doesn't match with your graph at all. – Disintegrating By Parts Mar 21 '17 at 11:11

0 Answers0