0

Find the Fourier series S(t) of the period $2\pi$ function

$f(t)=\begin{cases} -1& \text{if −$\pi$ < t < 0;}\\ \;\;1& \text{if $\:$0 < t < $\pi$;}\\ \;\;0&\text{if $t = −\pi, 0, or \;\pi$ } \end{cases}$

Use MATHEMATICA to graph partial sums $S_N(t)$ of the Fourier series for f(x) with N = 3, 6, 12, 24. What do you notice? Depending on the correctness of your $S_N(t)$, your graphs should portray what is known as Gibbs’s phenomenon.

For Fourier sine coefficients $b_n$ of the square wave, I get:

$b_n =\frac{2}{\pi} \int\limits_0^\pi$sin nx dx = $\frac{2}{\pi}[\frac{-cos\; nx}{n}] x = 0$ to $\pi$

$\frac{cos n\pi}{n}=\begin{cases} 0& \text{if n is even}\\ \frac{4}{n\pi}& \text{if n is odd} \end{cases}$

Thus for n = 1, 2, 3, 4, 5...

I get:

{$\frac{4}{\pi},0,\frac{4}{3\pi}, 0, ... $} I have difficulty in partial graphing sums. I need some help.

Avinesh
  • 533

1 Answers1

1

You are not summing the coefficients, but rather the sine series having these coefficients. Thus you want the graphs of

$$\frac{4}{\pi} \sin{x} + \frac{4}{3 \pi} \sin{3 x} + \cdots + \frac{4}{(2 N+1) \pi} \sin{(2 N+1) x}$$

over $x \in [-\pi,\pi]$ for various values of $N$.

Ron Gordon
  • 138,521
  • Thanks, any example codes that I can use in Mathematica. – Avinesh Oct 09 '13 at 13:16
  • @Avinesh: f[x_,n_] := (4/Pi) Sum[Sin[(2 k+1) x]/(2 k+1),{k,0,n}]; Plot[Table[f[x,n],{n,5}],{x,-Pi,Pi}] – Ron Gordon Oct 09 '13 at 13:42
  • The code doe not work for Mathematica version 5.2. The only version I have. Is there other way of writing in older version. – Avinesh Oct 10 '13 at 00:05
  • @Avinesh: for that, ask someone in mathematica.stackexchange,com – Ron Gordon Oct 10 '13 at 00:08
  • I tried this and it worked. s[n_, x_] := 4/( π) Sum[Sin[(2 k + 1) x]/(2 k + 1), {k, 0, n}]

    partialsums = Table[s[n, x], {n, 1}]; Plot[Evaluate[partialsums], {x, -π, π}]. How can I colour the curves?

    – Avinesh Oct 10 '13 at 02:25