Okay, thanks, what was not so clear to me is how to use the "three dots" 
notation to hand some points over to the integration function. For example, 
to integrate 1/z along the unit circle around the pole at the origin:

    julia> x = linspace(0, 2*pi);

    julia> points = exp(x*1im);

    julia> quadgk(z -> 1 ./ z, points...)
    (-2.1630337481358435e-17 + 6.283185307179583im,5.957695483631124e-16)

That is the correct solution  2 \pi i  to a very good accuracy.


On Friday, July 18, 2014 6:53:58 PM UTC+2, Steven G. Johnson wrote:
>
>
>
> 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
>

Reply via email to