Linear Methods of Applied Mathematics Differentiating Fourier series

This is an evaluated Mathematica notebook. Since the notebook is intended to be interactive, it may be helpful to also view the unevaluated version

In:=

Differentiating Fourier series. Let's begin by reminding Mathematica about
some identities we will use:

In:=

R1 = {Cos[Pi n_] -> (-1)^n, Sin[Pi n_] -> 0}
Clear[c]
Clear[f]

In this notebook we will use the complex form of the Fourier series. As you
recall, the complex series is completely equivalent to the full real series, with
both sines and cosines. You may find it instructive to set the calculations
up with the real functions for comparison. The complex Fourier coefficients
for a function f on an interval (a,b) are given by the formula:

In:=

c[k_,f_,a_,b_] := (1/(b-a)) Integrate[f[x] Exp[-2 Pi I k x/(b-a)], {x,a,b}]

In:=

f[x_] := 1

In:=

c[k,f,0,Pi]

Out=

-I   I  -2 I k Pi
--   - E
2    2
-- + ------------
k         k
-----------------
Pi

In:=

% /. k -> 2

Out=

0

In:=

%% /. k -> 3

Out=

0

In:=

c[0,f,0,Pi]

Out=

1

Recall that % refers to the previous calculation, %% to the one before that,
etc. The phrase /. k -> 3 tells Mathematica to evaluate the expression with
the additional rule that k = 3.

So, we appear to be up and running. A question to ponder: What would
have happened if I had written %%% /. k -> 0 in the line above?

Let's now calculate some more series. Suppose that

In:=

f[x_] := x - x^3

In:=

c[k,f,-1,1] /.{E^(I Pi k) -> (-1)^k,E^(-I Pi k) -> (-1)^k}

Out=

k                    2   2
(-1)  (6 - 6 I k Pi - 2 k  Pi )
(-(-------------------------------) +
4   4
k  Pi

k                    2   2
(-1)  (6 + 6 I k Pi - 2 k  Pi )
-------------------------------) / 2
4   4
k  Pi

In:=

Simplify[%]

Out=

k
6 I (-1)
---------
3   3
k  Pi

If we want a plot, it will be best to use real quantities, so recall that this is
an odd function, with only sines in the usual Fourier series.

FSeries[x_, N_] = Sum[-12 (-1)^k Sin[ Pi k x ] /(k Pi)^3, {k, 1, N} ]

In:=

FSeries[x_, N_] = Sum[-12 (-1)^k Sin[ Pi k x ] /(k Pi)^3, {k, 1, N} ]

Out=

k
-12 (-1)  Sin[k Pi x]
Sum[---------------------, {k, 1, N}]
3   3
k  Pi

In:=

Plot[{f[x], FSeries[x,3]}, {x,-1,1}]

Out=

-Graphics-

Wonderful! What happens if we differentiate? We get either the formula
1 - 3 x^2 or else the series

In:=

D[FSeries[x,N],x]

Out=

k
-12 (-1)  Cos[k Pi x]
Sum[---------------------, {k, 1, N}]
2   2
k  Pi

In:=

%/. N -> 4

Out=

12 Cos[Pi x]   3 Cos[2 Pi x]   4 Cos[3 Pi x]
------------ - ------------- + ------------- -
2               2                2
Pi              Pi             3 Pi

3 Cos[4 Pi x]
-------------
2
4 Pi

In:=

Plot[{1 - 3 x^2, %}, {x, -1,1}]

Out=

-Graphics-

Super! Just for fun, let's see the comparison outside the interval where we
cut off the polynom