Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.4K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Solution values doubled in Fourier series problem output?

I am trying to solve the following Fourier Series problem.

$$f(x)=\begin{cases} -1,& -1<x<0 \newline \;\; 1,&\;\; 0<x<1 \end{cases}$$

We know that on the interval $[-1,1]$ is odd. We calculate the coefficients $$a_0=0 , \quad a_n=0 , \quad b_n=\frac{4}{n\pi}$$

Thus,

$$f(x)= \sum_{n=1}^{\infty} \frac{4}{n\pi} \sin(n \pi x) $$

I tried to study the same problem on Mathematica with the following code

a[n_] := (2/L)*Integrate[f[x]*Cos[2 n*Pi*x/L], {x, -L/2, L/2}]
a[0] := (1/L)*Integrate[f[x], {x, -L/2, L/2}]
b[n_] := (2/L)*Integrate[f[x]*Sin[2 n*Pi*x/L], {x, -L/2, L/2}]
F[x_, N_] := a[0] + Sum[a[n]*Cos[2 n*Pi*x/L] + b[n]*Sin[2 n*Pi*x/L], {n, 1, N}]
p[N_, a_] := 
 Plot[Evaluate[F[x, N]], {x, -a, a}, PlotRange -> All, 
  PlotPoints -> 200]
L=2;
f[x_] = If[x > 0, 1, -1];
a[n]
a[0]
b[n]
Simplify[%, n \[Element] Integers]
Table[F[0.5, k], {k, 0, 20}]

enter image description here enter image description here

We notice that with the exception of the first value all other values are double. Why is this phenomenon observed? I know that is more a maths question than a Mathematica one but I would appreciate any help.

5 Replies
POSTED BY: Gianluca Gorni

Yes this is the notebook with my results

The series formula f(x)=∑n=1∞4nπsin(nπx) does not reproduce the function f(x)={−1,1,−1<x<00<x<1. It is the series for another function. Didn't you make the plot?

POSTED BY: Gianluca Gorni

Could you explain to me please why the F(x) is wrong?

Your formula for f[x] is wrong. Try plotting the result:

Sum[4/(n Pi) Sin[n Pi x], {n, 1, Infinity}]
Plot[Chop[%], {x, -1, 1}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard