Fourier Basis

grid = 200
domain = [0, 2*π]
dx = (domain[1]-domain[0])/grid
grid = np.linspace(*domain, grid)

def fourier(k, x): return sin(k*x)+cos(k*x)
n = 5

basis = pd.DataFrame({k: fourier(k, grid) for k in range(1,n)}, index=grid)
ax = basis.plot.line(lw=0.4, xlim=domain)
ax.axhline(0, c='black', lw='0.3')
<matplotlib.lines.Line2D at 0x136a4e890>
from scipy import integrate

def compare_two(i, j):
    product = pd.Series(basis[i]*basis[j], name='product')
    product = pd.DataFrame([basis[i], basis[j], product]).T

    ax = product.plot.line(lw=0.5, color=['red', 'blue', 'purple'])
    ax.fill_between(grid, product['product'], alpha=0.1)

    return integrate.trapz(product['product'], x=product.index)
print('integral =', np.round(compare_two(3,4), 4))
integral = -0.0

"fourier modes as eigenfunctions of the derivative operator" What?

Polynomial Bases