On Friday, July 18, 2014 8:06:25 AM UTC-4, Hans W Borchers wrote:
>
> First, I think, Steven is talking about line integrals along a path, and
> these integrals are one-dimensional.
>
> And secondly, of course you should avoid poles along your path, by making
> the radius big enough, or similar. These things are standard techniques in
> complex analysis.
>
Note also that if you have poles "on" your path, then you need more
information in order to define what your integral even means. e.g. do you
mean the limit as the pole approaches the path (or vice versa), and if so
you need to specify from what side you are taking the limit. Then you can
(for example) deform your integration contour away from the pole (in the
correct direction) as Hans suggests.
As an example, I append a function `line_integral` from my package
> NumericalMath (not in METADATA) that does integrate along a path given by
> `points`.
>
Hans, note that quadgk already supports line integration over straight
line-segments in the complex plane along any arbitrary sequence
points::Array{Complex} of points. Just do:
quadgk(f, points...)
This is better than doing the integral over each line segment separately,
because it is globally adaptive: in order to decide whether it needs to
subdivide any interval to improve accuracy, it will look at *all* the
intervals, not just the intervals within a single line segment.
Also, there is no need to integrate the real and imaginary parts
separately. quadgk can integrate complex-valued functions (and
vector-valued functions, and matrix-valued functions, and...) just fine.
By default, it measures the error in the usual norm sqrt(real^2 + imag^2),
but if you want to use min(|real|,|imag|) instead (which is effectively
what you are doing if you integrate them separately), then you can pass
that norm for the "norm" keyword argument.
--SGJ