  We present a numerical framework for computing nested quadrature rules for
various weight functions. The well-known Kronrod method extends the
Gauss-Legendre quadrature by adding new optimal nodes to the existing Gauss
nodes for integration of higher order polynomials. Our numerical method
generalizes the Kronrod rule for any continuous probability density function on
real line with finite moments. We develop a bi-level optimization scheme to
solve moment-matching conditions for two levels of main and nested rule and use
a penalty method to enforce the constraints on the limits of the nodes and
weights. We demonstrate our nested quadrature rule for probability measures on
finite/infinite and symmetric/asymmetric supports. We generate
Gauss-Kronrod-Patterson rules by slightly modifying our algorithm and present
results associated with Chebyshev polynomials which are not reported elsewhere.
We finally show the application of our nested rules in construction of sparse
grids where we validate the accuracy and efficiency of such nested
quadrature-based sparse grids on parameterized boundary and initial value
problems in multiple dimensions.
