# Interpolation-weighted quadrature rules

**URL:** <https://discourse.julialang.org/t/interpolation-weighted-quadrature-rules/32170>\
**Category:** Numerics\
**Created:** [December 11, 2019, 8:32pm UTC](https://discourse.julialang.org/t/interpolation-weighted-quadrature-rules/32170 "2019-12-11T20:32:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 11, 2019, 8:32pm UTC](https://discourse.julialang.org/t/interpolation-weighted-quadrature-rules/32170/1 "2019-12-11T20:32:09Z")

</div>

Some of you might be interested in the following notebook, which shows how to construct optimal Gaussian quadrature schemes for arbitrary weight functions constructed from interpolated data:

- [Notes on Solar-Weighted Gaussian quadrature](https://nbviewer.jupyter.org/urls/math.mit.edu/~stevenj/Solar-Quadrature.ipynb?flush_cache=true)

using a recently added feature of the [QuadGK.jl package](https://github.com/JuliaMath/QuadGK.jl).

The example in this notebook is on constructing quadrature rules

\int S(\lambda) f(\lambda) d\lambda \approx \sum\_{i=1}^N w\_i f(\lambda\_i)

for a weight function S(λ) given by the [solar irradiance spectrum](https://www.nrel.gov/grid/solar-resource/spectra-am1.5.html), an extremely oscillatory weight derived from tabulated measurements. By constructing a Gaussian quadrature rule where S(λ) is “built in”, one can compute the integral for smooth f(λ) using very few points, which is very useful for solar-cell modeling where f(λ) is computed by solving Maxwell’s equations.

The notebook includes a general function `gaussquad_interpolant` that you can use to construct quadrature rules for any tabulated data.

---

<div class="post-metadata">

**Author:** ![lwhitefox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lwhitefox/32/4363_2.png) [@lwhitefox](https://discourse.julialang.org/u/lwhitefox)\
**Post date:** [January 22, 2020, 8:56pm UTC](https://discourse.julialang.org/t/interpolation-weighted-quadrature-rules/32170/2 "2020-01-22T20:56:07Z")

</div>

A little slow in seeing this, but it looks cool, thanks!
