def fourier(x, N):
    """Fourier approximation with N terms"""

    term = 0.
    for n in range(1, N, 2):
        term += (1. / n) * math.sin(n * math.pi * x / L)
    return (4. / (math.pi)) * term
Fourier approximation with N terms