Can I do an integral, possibly using Gaussian quadrature, when the abscissas are fixed (for reasons that I don't want to get into right now); i.e., is it possible to calculate the weights for fixed abscissas that I don't get to choose?
closed as too localized by Gerry Myerson, t.b., sdcvvc, Michael Greinecker♦, William Aug 31 '12 at 6:39
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
In fact, if the abscissas $x_i$ of a weighted interpolatory quadrature rule
$$\int_a^b w(x) f(x)\;\mathrm dx\approx\sum_i w_if(x_i)$$
are given, and you need to generate the corresponding weights $w_i$, there are algorithms by Sylvan Elhay and Jaroslav Kautsky (based on earlier work by Kautsky and Gene Golub for the case of quadratures with both fixed and free knots) that are based on symmetric eigenvalue methods a la Golub-Welsch, and are slightly more stable than the usual approach of solving the Vandermonde system generated by the moments $\int_a^b w(x) x^k\mathrm dx$. They have published a FORTRAN implementation of their methods in the ACM Collected Algorithms; translating that into your favorite computing language (if you're not using FORTRAN, that is) is entirely up to you.
On the other hand, if you do have exact values for the $x_i$ and the moments $m_i=\int_a^b w(x) x^k\mathrm dx$ available, and you can do exact arithmetic, solving the Vandermonde system is feasible.
In particular, remember that for a weighted $n$-point quadrature rule with $n$ preset abscissas, it is customary to demand that the quadrature rule be able to exactly integrate functions of the form $w(x)p(x)$, where $p(x)$ is a polynomial with an degree from $0$ to $n-1$. ($n-1$ points uniquely determine a corresponding $n$-th degree polynomial passing through those points). However, it may well be that due to the special configuration/distribution of the points, the quadrature rule could do much better than expected. (Two examples come to mind: Simpson's rule is meant to be exact for quadratics, but is able to integrate cubics exactly, and the $n$-point Clenshaw-Curtis rule, whose $x_i$ are the extrema of Chebyshev polynomials, behaving favorably with regards to accuracy.) Newton-Cotes is but a special case of this, where the $x_i$ are equispaced over the integration interval.
Thus, to obtain the weights $w_i$ from the $x_i$ and the $m_i$, one needs to solve the primal Vandermonde system
Gaussian elimination will work here, but it is more economical to use the Björck-Pereyra algorithm, which is based on Newton interpolation. This takes $O(n^2)$ effort as opposed to the $O(n^3)$ effort needed by Gaussian elimination.
But, again, for inexact arithmetic, the methods by Elhay and Kautsky will (generally) give more accurate values for the weights.
As a last warning, you will want to check the signs of the weights, whether you compute them through the Vandermonde route or the Elhay-Kautsky route. Beware if the weights are not of the same sign; it usually means that the underlying interpolating polynomial is quite oscillatory, and there might be cancellation of significant digits when the quadrature formula is used.
Absolutely. Section 4.5 of Numerical Recipes describes how, as will many numerical analysis books. Obsolete versions are free.