0

Determine the fourier series for the function defined by:

$f(x) = 2x$ for $0 < x < 2\pi$, and $f(x+2\pi) = f(x)$

The Fourier series coefficients are defined as follows:

$$A_0 = \frac{1}{2\pi}\int_{-\pi}^{\pi} f(x) dx$$ and, for $n \geq 1$, $$A_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x) \cos(nx) dx$$ $$B_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x) \sin(nx) dx$$

I have three questions.

Is $A_0 = 0$ ? Is $A_n = 0$? Is $B_n =$ (something nonzero)?

Here is my reasoning: https://gyazo.com/e91c055d76da4837082c79be73f494bc

This has been my approach so far. I can't seem to get the right answer so I have to root out what I am doing wrong with some help. I am attempting to do fourier series for the first time ever.

Here is the graph I have drawn:

https://gyazo.com/70bc06f7eedb101e0f46a1619328fbc2

I am also looking for some kind webpage or program where I can plot in the information I have to get a correct answer.

  • What formulas do you have for $A_n$ and $B_n$? Note that your three questions can be answered without evaluating the integrals. See if you can understand why $A_0$ will be zero if and only if the average value of $f$ over $[0,2\pi]$ is zero. Also, observe that the integrals are the same whether you integrate from $0$ to $2\pi$ or from $-\pi$ to $\pi$. What conditions on $f$ would suffice to make these integrals zero? (Hint: consider odd and even functions.) –  Dec 11 '15 at 20:45
  • @Bungo Hi Bungo. Thank you for your answer. I am updating the OP with my formulas. I also know about the things, odd or even. I also know that you can integrate the same plus part of the integral and times by 2 instead of going from negative to positive. – David Lund Dec 11 '15 at 20:48
  • I edited your post to add the formulas for the coefficients. If you click "edit", you will be able to see how I did it, in case you want to try MathJax typesetting in future questions (which is encouraged!) –  Dec 11 '15 at 21:12

1 Answers1

2

I'm reproducing your original link to the formulas you are using for completeness: https://gyazo.com/81653210303c42b1b5dcdae717690842

Here is a typeset version in case the link goes stale in the future: $$a_0 = \frac{1}{2L}\int_{-L}^{L} f(x) dx$$ and, for $n \geq 1$, $$a_n = \frac{1}{L}\int_{-L}^{L} f(x) \cos\left(\frac{n\pi x}{L}\right) dx$$ $$b_n = \frac{1}{L}\int_{-L}^{L} f(x) \sin\left(\frac{n\pi x}{L}\right) dx$$ These formulas are in a slightly nonstandard form. At first glance, you might expect that $L$ is the period of the function $f$. But in fact, when computing Fourier series coefficients, we always integrate over one period. These integrals are taken over $[-L,L]$, which has length $2L$, so in fact this means that $L$ is half of the period. Your function has period $2\pi$, so we need to take $L = \pi$.

Rewriting your formulas with $L = \pi$ gives us $$a_0 = \frac{1}{2\pi}\int_{-\pi}^{\pi} f(x) dx$$ and, for $n \geq 1$, $$a_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x) \cos(nx) dx$$ $$b_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x) \sin(nx) dx$$ Notice that the formula for $a_0$ is simply the average value of $f$ over the interval $[-\pi, \pi]$. You should be able to see at a glance that the average of your function is nonzero: indeed, it is strictly positive because the function is always nonnegative, and each "triangle" has positive area.

Now, look at the defining integrals for $a_n$ and $b_n$. See if you can convince yourself that if we replace $f(x)$ with $g(x) = f(x) - a_0$, the values of $a_n$ and $b_n$ do not change. This is because $\int_{-\pi}^{\pi} a_0 \cos(nx) dx = \int_{-\pi}^{\pi}a_0 \sin(nx) dx = 0$ since $a_0$ is just a constant.

Observe that $g(x) = f(x) - a_0$ is odd: you can see this by shifting the graph downward by $a_0$. That means that one of the integrals will be zero (which one?)

  • Nicely done sir! – TeeJ Lockwood Dec 11 '15 at 21:08
  • But where does -pi to pi come from? I thought L was 2pi. How can I just rewrite it like that? I thought I was going to integrate one period. So from -2pi to 2pi I guess. I realize now that's 2 periods .. but it still says L in the formulas, so I am a little bit confused. I have a rule that says if a function is odd it's, 0, so is my graph drawn wrong? – David Lund Dec 11 '15 at 21:18
  • Your function has period $2\pi$. If you integrate from $-2\pi$ to $2\pi$ you will be integrating over two periods, not one. Note that your function $f$ is not odd. An odd function satisfies $f(-x) = -f(x)$ for all $x$. If we plug in $x=\pi$ for example, your function gives us $f(\pi) = 2\pi$ and $f(-\pi) = 2\pi$ (not $-2\pi$), so $f$ is not odd. However, if we shift your function downward by $2\pi$ we get a new function $g(x) = f(x) - 2\pi$ which is odd. –  Dec 11 '15 at 21:21
  • Can I integrate from 0 to 2pi instead then? It seems easier. But, wouldn't I get different answers if pick different points on the x-line, because the triangles wouldn't be always the same? or is the area the same because in one period no matter where I pick the area is always the same? – David Lund Dec 11 '15 at 21:28
  • You can integrate from $0$ to $2\pi$ or from $-\pi$ to $\pi$ or any other interval of length $2\pi$. I used $-\pi$ to $\pi$ because your formulas are given that way, and also, using an interval which is symmetric around the origin makes it easier to see what happens when you have an odd or even function. –  Dec 11 '15 at 21:30
  • Oh, I understand the formula now. Then I rather forget it and just integrate for one period at the numbers at my choice. 0 to something seems easier. Less work. I am taking a look at why my function is not odd. I thought it was odd if -x,-y and x,y didnt hit the same spot on graph, over the y-axis. Also, do you have a link to the standard formulas? – David Lund Dec 11 '15 at 21:39
  • Sure, you can always integrate over whichever interval is easiest to work with. Often, choosing the interval correctly will make the integrals easier to compute. Check the Wikipedia page for even and odd functions. In particular, look at their plots of $x^3$ (which is odd) and $x^3 + 1$ (which is not odd). This is similar to your situation. Your function as given is not odd, but you can shift it vertically by a constant to make it odd. –  Dec 11 '15 at 21:43
  • I still dont see how 2x is even. Even functions are f(x) = f(-x). So if we say x = 2. say 22=2-2.. Also, I have another question thinking about it. It isn't enough to check with only f(x)=f(-x) for example. A function can be nor odd or even right? – David Lund Dec 11 '15 at 22:05
  • You are only taking the segment of $2x$ from $x=0$ to $x=2\pi$, then repeating this periodically. Consequently, the function $f(x)$ is always nonnegative. If a function takes on positive values but not negative values, it cannot be odd. Note, unlike with numbers, the fact that a function is not even does NOT mean it is odd. Most functions are neither even nor odd. –  Dec 11 '15 at 22:08
  • Okey, I get what you mean. If my function was 2x x=-1 to x=1 things would have been different? Anyway, thanks. I am going to solve it now, as we have rooted what my problem. – David Lund Dec 11 '15 at 22:33
  • Yes, that's correct. If it was $2x$ from $x=-1$ to $x=1$, then extended periodically, that would be an odd function. –  Dec 11 '15 at 22:50
  • What is L if you choose to integrate from 0 to 2pi. I realize that I am not getting the same answers by trying to integrate from -pi to pi, and 0 to 2pi, and then multiplying them with 1/2L. Now I realize why that is, by watching a graph. -pi to pi integrates below, and above and adds them together to nothing. Not correctily like it should. As you said, it's all positive so it's not going to become 0. I am not sure what the other one will be either because then I am not sure what L is. – David Lund Dec 12 '15 at 00:04
  • The integral in the formula is taken over $[-L,L]$, which has length $2L$. You can integrate over any interval of length $2L$ and the integral will give the same result. In your case, you were integrating over $[-\pi,\pi]$ so $L=\pi$. That will still be the case if you integrate over $[0,2\pi] = [0,2L]$. No matter which interval you use, $L$ should be half the period of $f$. –  Dec 12 '15 at 01:11
  • 1
    @Bungo. I thank you for your help. I have an exam in 3 days, and I learned Fourier series in one day. I managed to do the fourier series on older exam papers very easily. – David Lund Dec 12 '15 at 18:58