Juliaで複素積分

複素積分∮の定義

In [228]:
function (f,path)
    s=0
    for i in 2:length(path)
        s=s+f((path[i]+path[i-1])/2)*(path[i]-path[i-1])
    end
    return s
end
Out[228]:
∮ (generic function with 1 method)

複素平面上での四角い積分経路

In [236]:
function (leftdown,rightup,num)
    r1=real(leftdown)
    r2=real(rightup)
    i1=imag(leftdown)
    i2=imag(rightup)
    a=linspace(r1,r2,num)+i1*im
    b=linspace(i1,i2,num)*im+r2
    c=linspace(r2,r1,num)+i2*im
    d=linspace(i2,i1,num)*im+r1
    return vcat(vcat(a,b),vcat(c,d))
end
Out[236]:
□ (generic function with 4 methods)

複素関数

In [245]:
g(z)=z*3
f(z)=1/z
Out[245]:
f (generic function with 1 method)

gは極を持たない複素平面全域で正則な関数

fは原点に極を持つ

積分の実行

極を囲わない積分路

In [237]:
cc=(3+im,4+3*im,4)
(g,cc)
Out[237]:
8.881784197001252e-16 + 3.552713678800501e-15im
In [238]:
(g,(3+im,0+im,4))
Out[238]:
0.0 + 0.0im
In [239]:
cr=(1+im,3+im)
(g,cr)
Out[239]:
1.5543122344752192e-15 - 4.440892098500626e-16im
In [242]:
c=(1+im,3+2*im)
println((g,c))
println((f,c))
1.0547118733938987e-15 - 3.552713678800501e-15im
-0.00018306775067675196 + 0.0009021823204503621im

fの極を囲う積分路

In [243]:
c=(-5+-5im,4+4*im)
println((g,c))
println((f,c))
0.0 + 0.0im
9.71445146547012e-17 + 6.291421562431563im
In [251]:
2*π
Out[251]:
6.283185307179586
In [ ]: