Orthogonal Functions

What does it mean for functions to be orthogonal?

In [1]:
#collapse
# imports
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import scipy.stats

%matplotlib inline
plt.rcParams['figure.figsize'] = [12, 5]
plt.rcParams['figure.dpi'] = 140

π = np.pi
exp = np.exp
sin = np.sin
cos = np.cos
sqrt = np.sqrt

Fourier Basis

In [44]:
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)
In [45]:
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')
Out[45]:
<matplotlib.lines.Line2D at 0x136a4e890>
In [46]:
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)
In [47]:
print('integral =', np.round(compare_two(3,4), 4))
integral = -0.0

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

Polynomial Bases

In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: