I am trying to get Fourier sine series for $$ f(x) = \left\{ \begin{array}{lr} 3 & : 0\le x\le 6\\ 3-x & : 6\le x \le 9 \end{array} \right. $$

So far I know that the function is aperiodic, therefore I would have to construct what is called a "odd helper function" (at least in my native language), so that the helper function $$\varphi(x)=\left\{ \begin{array}{lr} f(x) &, if \quad x\in[0;l]\\ -f(-x) &, if \quad x\in[-l;0] \end{array} \right.$$ ,where $l=9$.

So my $\varphi(x)$ would look like: $$\varphi(x)=\left\{ \begin{array}{lr} 3 &, if \quad x\in[0;6]\\ 3-x&, if \quad x\in[6;9]\\ -3 &, if \quad x\in[-6;0]\\ -3-x &, if \quad x\in[-9;-6] \end{array} \right.$$ Then I assume that I need to evaluate $$b_n=\frac{2}{l}*\int_0^l{\varphi(x)*\sin{\frac{n*\pi*x}{l}}dx}$$ And the Fourier series would be $$f(x)=\sum_{n=1}^{\infty}{b_n \cdot \sin{\frac{n\cdot\pi\cdot x}{l}}}$$ But when I try to plot this sum up to $n=5$, this does not look anything like my initial piecewise function. What am I doing wrong?


1 Answer 1


Original answer

You need to integrate from $-l$ to $l$ when calculating $b_n$ in order to cover the complete "helper function". Also, when expanding the integration interval, the $2$ in the nominator should be changed to $1$.

$$b_n=\frac{1}{l}\int_{\color{red}{-l}}^l{\varphi(x)\sin{\frac{n\pi x}{l}}dx}$$

Edit in response to original poster's own answer

I deleted the above because I realized that this is the same expression as you have for $b_n$ in the question. This is true since $\varphi(x)$ is odd:

$$\begin{align} b_n&=\frac1l\int_l^lf(x)\;\mathrm dx\\ &=\frac1l\int_{-l}^0f(x)\;\mathrm dx+\frac1l\int_0^lf(x)\;\mathrm dx\\ &=\frac1l\int_{0}^{l}-f(-x)\;\mathrm dx+\frac1l\int_0^lf(x)\;\mathrm dx\\ &=\{\text{ f is odd }\}\\ &=\frac2l\int_0^lf(x)\;\mathrm dx \end{align}$$

And since $f(x)=\varphi(x)\sin\frac{n\pi x}{l}$ is indeed odd, your expression for $b_n$ in the question should be ok. You might have made an error calculating the $b_n$ using this expression.

  • $\begingroup$ Ok, this is already better. I tried to plot this sum up to $n=18$, but in $x\in[0,6]$ it seems to converge to $y=6$, rather than $y=3$. $\endgroup$ Dec 10, 2014 at 17:03
  • $\begingroup$ @KristiansKuhta I edited the answer. Have a look and see if it helps. $\endgroup$
    – Daniel R
    Dec 10, 2014 at 17:08
  • $\begingroup$ Still I do not understand why would there be $\varphi (x)=-3+x \quad\forall x\in[-9;-6]$. The $\varphi (x)$ is defined as $-f(-x)$ in that region. $\endgroup$ Dec 12, 2014 at 15:19
  • $\begingroup$ No, you are totally right, yet another error on my part. Sorry! $\endgroup$
    – Daniel R
    Dec 12, 2014 at 15:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .