Fourier Series

Overview


Fourier Series Expansion


The following code demonstrates using the integration api to calculate the first set of coefficients


let it = await import('/lib/numeric/integration/v1.0.0/integration.mjs');
let f = x=> x*x;

let a0 = (1/Math.PI) * it.midPoint(x=>f(x),{
  lower:-1 * Math.PI,
  upper: Math.PI,
  numberMeshPoints:1000
});

let a1 = (1/Math.PI) * it.midPoint(x=>f(x)*Math.cos(x),{
  lower:-1 * Math.PI,
  upper: Math.PI,
  numberMeshPoints:1000
});

let a2 = (1/Math.PI) * it.midPoint(x=>f(x)*Math.cos(2*x),{
  lower:-1 * Math.PI,
  upper: Math.PI,
  numberMeshPoints:1000
});
					
Try it!