Block 84: SciPy: Integration & Interpolation
Numerically integrate functions and interpolate between data points.
Concepts
- scipy.integrate.quad() for definite integrals
- Error estimation from quad()
- scipy.interpolate.interp1d() for data interpolation
- Linear vs cubic interpolation
Code Examples
See exercise below.
Exercise
Numerically integrate sin(x) from 0 to π. Compare with exact answer of 2. Interpolate between 10 sparse data points and plot both original and interpolated curve.
Homework
When would you use numerical integration instead of symbolic integration? Wednesday