Leibniz Formula

Apr 18 2016

Verify Leibniz formula using Fourier series expansion

Let's consider a sawtooth wave function as follow.

f(x) = x       (-pi < x < pi)
f(x + 2 n pi) = f(x)

We calculate the Fourier coefficients of this function.

f(x) = a_0 / 2 + sum_(k=0) a_k cos(k x) + sum_(k=0) b_k sin(k x)

In the program, we calculate the following expressions to get the Fourier coefficients.

a_0 = 1 / pi int_(-pi)^pi f(x) dx = 0

a_k = 1 / pi int_(-pi)^pi f(x) cos(k x) dx = 0

b_k = 1 / pi int_(-pi)^pi f(x) sin(k x) dx = (2 (-1)^k) / k

Then, we get

f(x) = sum_(k=0) ((2 (-1)^k sin(k x)) / k).

If we substitute x with pi / 2 in the above equation, we get Leibniz formula as follow.

pi / 4 = 1 - 1 / 3 + 1 / 5 - 1 / 7 + 1 / 9 - ...