函数:PluralGammaLower(s,x)
s:一个复数变量
x:一个复数变量
说明函数成功返回对应的向下的不完全伽马函数值
原理:
1、这里求解的是向下的不完全伽马函数,具体的参看
2、本代码求解的不完全伽马函数有如下形式的级数展开形式
2.1、很明显,我们可以设
A[2*n+1]=s+2*n+1+z*(n+1)/{s+2*n+2-(s+n+1)*z/A[2*n+3]},其中n=0,1,2,……
则我们求解的函数=z^s*e^(-z)/{s-sz/A}
2.2、
一般地,当n趋近于∞时,A[2*n+1]≈A[2*n+3],在这里我们截取前n项,令x=A[2*n+1]=A[2*n+3],带入上面2.1式我们有如下的方程
C*x^2-(A*c+D+B)*x+A*D=0
其中
A=s+2*n+1
B=z*(n+1)
C=s+2*n+2
D=(s+n+1)*z
那么我们很容易得到两个x的解,一般地这里我们选取x离C近的解作为我们实际的解
2.3、令A[2*n+3]=x,然后回代入2.1式算出A,进而算得我们的不完全伽马函数
2.4、这里需要注意,上面的算法只能在s为非负整数时才能使用.
引用:
PluralMul:复数乘法
PluralSqrt:复数开方
PluralDiv:复数除法
PluralPow:复数求次方
PluralExp:复数求指数次方
例子:
a = i
c=PluralGammaLower(a,a)
c= -0.140125009678925 - 0.281466640628561i
源代码:
Public Function PluralGammaLower(ByVal s As Plural, ByVal x As Plural) As Plural
'不完全Gamma函数的级数展开求解方法
'参考
Dim nz, sz, sn, ret, A, B, C, D, An As New Plural
Dim n As Integer = 100
A.Real = s.Real + n + n + 1
A.Imag = s.Imag
C.Real = A.Real + 1
C.Imag = A.Imag
nz.Real = A.Real - n
nz.Imag = A.Imag
D = PluralMul(nz, x)
B.Real = x.Real * (n + 1)
B.Imag = x.Imag * (n + 1)
nz = PluralMul(A, C)
sz.Real = nz.Real + D.Real + B.Real
sz.Imag = nz.Imag + D.Imag + B.Imag
sn = PluralMul(sz, sz)
ret = PluralMul(nz, D)
ret.Real += ret.Real
ret.Imag += ret.Imag
ret.Real += ret.Real
ret.Imag += ret.Imag
sn.Real -= ret.Real
sn.Imag -= ret.Imag
ret = PluralSqrt(sn)
A.Real = sz.Real + ret.Real
A.Imag = sz.Imag + ret.Imag
B.Real = sz.Real - ret.Real
B.Imag = sz.Imag - ret.Imag
C.Real += C.Real
C.Imag += C.Imag
sz = PluralDiv(A, C)
sn = PluralDiv(B, C)
A.Real = s.Real + n + n + 1
B.Real = (A.Real - sz.Real) ^ 2 + (A.Imag - sz.Imag) ^ 2
C.Real = (A.Real - sn.Real) ^ 2 + (A.Imag - sn.Imag) ^ 2
If B.Real < C.Real Then
An.Real = sz.Real
An.Imag = sz.Imag
Else
An.Real = sn.Real
An.Imag = sn.Imag
End If
B.Real = x.Real * n
B.Imag = x.Imag * n
n -= 1
A.Real = s.Real + n + n + 1
A.Imag = s.Imag
C.Real = A.Real + 1
C.Imag = A.Imag
D.Real = A.Real - n
D.Imag = A.Imag
While n >= 0
sn = PluralMul(D, x)
sz = PluralDiv(sn, An)
ret.Real = C.Real - sz.Real
ret.Imag = C.Imag - sz.Imag
nz = PluralDiv(B, ret)
An.Real = A.Real + nz.Real
An.Imag = A.Imag + nz.Imag
A.Real -= 2
B.Real -= x.Real
B.Imag -= x.Imag
C.Real -= 2
D.Real -= 1
n -= 1
End While
A = PluralMul(s, x)
B = PluralDiv(A, An)
C.Real = s.Real - B.Real
C.Imag = s.Imag - B.Imag
A = PluralPow(x, s)
B = PluralExp(x)
D = PluralMul(B, C)
ret = PluralDiv(A, D)
Return ret
End Function
在数学中,上不完全Γ函数和下不完全Γ函数是Γ函数的推广。
它们的定义分别如下:
基本性质有:
参考资料: