# do numerical integration with fixed abscissas

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?

-
Please see mathoverflow.net/howtoask - I'm not sure what to make of this question. –  David Roberts Aug 4 '11 at 23:31
Sorry if the question is not clear enough. Gaussian quadrature uses a set of polynomials, whose roots become the abscissas and then has a prescription for finding the weight for each abscissa. In my case I do not know the polynomials, only the abscissas beforehand, and would like to find the weights. Thanks. –  jackj Aug 4 '11 at 23:38
Question has also been posted to m.se, math.stackexchange.com/questions/55687/… –  Gerry Myerson Aug 5 '11 at 1:11

My interpretation of the problem: given $n$ pairs $(x_j, f(x_j)$ with $a \le x_1 < x_2 < \ldots < x_n \le b$, you want an approximation to $\int_a^b f(x)\, dx$.

One way, that would give the correct value for polynomials of degree $\le n-1$, would be to use $\int_a^b g(x)\, dx$ where $g$ is the Lagrange interpolating polynomial of degree $\le n-1$ corresponding to your data. However, that can be very unstable (see "Runge's phenonenon"). A better idea might be to use something like a composite quadrature rule: partition your interval into subintervals, each containing a few of the $x_j$, and use the interpolation for those $x_j$ in the subinterval to approximate the integral over that subinterval.

-
@Robert Israel: the problem I was trying to solve is precisely as you stated it. Thanks for the answer. So, essentially, many small-power polynomials are better than one large-power polynomial. What I plan to do is use the algorithm J.M. mentioned in each subinterval. –  jackj Aug 5 '11 at 18:19
@jackj: Right, so probably we could give better suggestions if you'd mention what those "fixed abscissas" look like... –  J. M. Aug 7 '11 at 9:28
@J. M. : sorry for the long delay in responding. My abscissas look like $\delta\sqrt{a+n^2}$ where $a$ is "small" and $n$ is an integer. –  jackj Aug 11 '11 at 20:09
You might map these to uniformly spaced abscissas by the transformation $t = \sqrt{x^2/\delta^2 - a}$. –  Robert Israel Aug 12 '11 at 1:29

You could fit a cubic spline through the given data points, and then integrate the cubics exactly.

-

I have settled this question here; in brief, a FORTRAN implementation of algorithms for solving this problem have been published in the Collected Algorithms of the ACM.

At the risk of being redundant, I'd like to mention here some other things I mentioned in the (now expanded) answer of mine at that other site for completeness' sake.

Robert's warning of the Runge phenomenon happening is a good one, and it does happen if your abscissas are perversely distributed (relatedly, the underlying Vandermonde matrix is ill-conditioned); the equispaced case being among the worst-behaved point distributions. Abscissas that are "nicely distributed" (e.g. Legendre, Chebyshev, or any other point distribution which "clusters" near the ends) will generally ensure that you have a quadrature rule that behaves tamely even for large numbers of points. (As an aside, the chebfun project hinges on functions being nicely approximated by interpolating polynomials with abscissas that are transformed Chebyshev polynomial roots/extrema.)

Lastly, whatever you finally settle with, you will want to perform the sanity check of ensuring that all the weights of your quadrature rule are of the same sign; any change of sign in the weights can lead to subtractive cancellation when you employ the quadrature rule, and you wouldn't want that...

-
This is without doubt the mathematically correct solution, but, as Robert Israel points out in another answer, it could be the solution to the wrong problem: interpolatory quadrature with badly-chosen nodes can give poor results. –  Federico Poloni Aug 5 '11 at 9:02
@Federico: OK, but I see no reason why I cannot combine J.M.'s solution with Robert Israel's point. Given this fact, I am accepting J.M's answer in the other thread, where he provides details, and Robert Israel's answer in this thread, where he provides the warning. –  jackj Aug 5 '11 at 18:16