# Simpson's Rule Equivalent for Line Integrals?

I recently coded a program that can estimate a line integral with respect to arc length.
For example:

$$\int_Cf(x, y) dS$$

Where C is represented by the parametric equations x(t) and y(t), a ≤ t ≤ b. To estimate this, I started by creating the variable $\delta = \frac {b-a}{n}$ where n is a large number. I then made the sum (from t=a to t=b by the increment of $\delta$) by averaging two consecutive points of f(x, y) along the path C using $\delta$ as the increment to find the "height" of the rectangle and multiplied it by the "base", which I found using $\sqrt{(x(t)-x(t+\delta))^2*(y(t)-y(t+\delta))^2}$.

Is it possible to estimate line integrals like this with a modified version of Simpson's Rule?

-
Why not just write the line integral as a (regular) integral in terms of the parameterization and use Simpson's rule on that? –  David Mitra Apr 1 '12 at 0:36
I would have some trouble handling the derivatives. It may be possible though, thanks. –  Argon Apr 1 '12 at 0:40
@Argon : You want to estimate an integral, the fact that it is a line integral or a non-line integral doesn't matter ; once you know that the number you want to estimate is a number, the rest is just technique ; as long as you know theoretically that it'll converge, the background behind the number doesn't matter if you can approximate successfully enough. –  Patrick Da Silva Apr 1 '12 at 0:48

It looks to me that dealing with $f^\prime(t)$ and $g^\prime(t)$ when you're unable or unwilling to compute analytic derivatives is what's giving you trouble; there are a number of numerical differentiation methods you can use along with Simpson's rule (but methinks you really should be using Gaussian quadrature instead). On the other hand, there is a simple strategem due to J.C. Nash for estimating derivatives, based on the central difference approximation

$$f(x)\approx\frac{f(x+h)-f(x-h)}{2h}$$

The trick here is to choose $h$ to be small, but not too small; Nash's suggestion is to use $h=\sqrt{\varepsilon}\left(|x|+\sqrt{\varepsilon}\right)$ where $\varepsilon$ is machine epsilon. This should be good enough for most purposes.

-