这是Module:Complex Number/Functions 的文档页面
三角函數擴充
擴充了原本未定義的三角函數
如sec(正割 )、 csc(餘割 )、 sech(雙曲正割)、 csch(雙曲餘割)、 asec(反正割 )、 acsc(反餘割 )、asech(反雙曲正割)、 acsch(反雙曲餘割)、 gd(古德曼函數 ) 、 cogd(餘古德曼函數)、 arcgd(反古德曼函數)
功能
輸入一個複數x,回傳其指定三角函數 的值
range(x,min,max)
功能
指取函數的某一段
若x位於min,max區間內,則回傳x,否則回傳NaN
factorial(x)
功能
輸入一個複數x,回傳其階乘 值
即factorial(x)
=
n
!
{\displaystyle =n!}
實作方式
參考#gamma(x)
gcd(a,b,c,...)
功能
計算a,b,c,....等數字的最大公因數 ,支援複數。
實作方式
輾轉相除法
gamma(x)
功能
輸入一個複數x,回傳其Γ函數 值
伽瑪函數 的實作方式
精確度
有效數字14位
實作方式
共分成4個部分
中間藍色部分是利用從零展開倒數伽瑪函數 的泰勒級數 定義
展開至前30項
1
Γ
(
z
)
=
z
+
γ
z
2
+
(
γ
2
2
−
π
2
12
)
z
3
+
⋯
{\displaystyle {\frac {1}{\Gamma (z)}}=z+\gamma z^{2}+\left({\frac {\gamma ^{2}}{2}}-{\frac {\pi ^{2}}{12}}\right)z^{3}+\cdots }
a
n
=
a
2
a
n
−
1
−
∑
j
=
2
n
−
1
(
−
1
)
j
ζ
(
j
)
a
n
−
j
n
−
1
{\displaystyle a_{n}={\frac {a_{2}a_{n-1}-\sum _{j=2}^{n-1}(-1)^{j}\,\zeta (j)\,a_{n-j}}{n-1}}}
[ 1]
兩側橘紅色部分是利用中間藍色代Γ函數 的遞迴關係式 定義,並用For迴圈 實作
Γ
(
x
+
1
)
=
x
Γ
(
x
)
{\displaystyle \Gamma (x+1)=x\Gamma (x)}
Γ
(
x
−
1
)
=
Γ
(
x
)
x
−
1
{\displaystyle \Gamma (x-1)={\frac {\Gamma (x)}{x-1}}}
上下的綠色部分則是使用Robert H. Windschitl (2002) 所提出的公式近似
Γ
(
z
)
≈
2
π
z
(
z
e
z
sinh
1
z
+
1
810
z
6
)
z
{\displaystyle \Gamma (z)\approx {\sqrt {\frac {2\pi }{z}}}\left({\frac {z}{e}}{\sqrt {z\sinh {\frac {1}{z}}+{\frac {1}{810z^{6}}}}}\right)^{z}}
[ 2]
最後黃色部分則是使用帶有斯特靈級數的斯特靈公式 近似
n
!
=
2
π
n
(
n
e
)
n
(
1
+
1
12
n
+
1
288
n
2
−
139
51840
n
3
−
571
2488320
n
4
+
⋯
)
.
{\displaystyle n!={\sqrt {2\pi n}}\left({n \over e}\right)^{n}\left(1+{1 \over 12n}+{1 \over 288n^{2}}-{139 \over 51840n^{3}}-{571 \over 2488320n^{4}}+\cdots \right).}
[ 3]
展開至前16項 (來源:(OEIS 數列A001163 )、(OEIS 數列A001164 ))
而背景透明標記 (灰白相間) 部分則為超出浮點數 可儲存範圍,會溢位 或出現inf或nan
最左邊土黃色則是可能出現低於設計的精確度小數12位而回傳0
參考文獻
^ Wrench, J.W. (1968). Concerning two series for the gamma function. Mathematics of Computation , 22 , 617–626. and Wrench, J.W. (1973). Erratum: Concerning two series for the gamma function. Mathematics of Computation , 27 , 681–682.
^ Toth, V. T. Programmable Calculators: Calculators and the Gamma Function (2006) 互联网档案馆 的存檔 ,存档日期2005-12-31.
^ F. W. J. Olver, A. B. Olde Daalhuis, D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller, and B. V. Saunders, eds. NIST Digital Library of Mathematical Functions .