同步操作将从 编程语言算法集/Python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import mathfrom numpy import inffrom scipy.integrate import quaddef gamma(num: float) -> float:"""https://en.wikipedia.org/wiki/Gamma_functionIn mathematics, the gamma function is one commonlyused extension of the factorial function to complex numbers.The gamma function is defined for all complex numbers except the non-positiveintegers>>> gamma(-1)Traceback (most recent call last):...ValueError: math domain error>>> gamma(0)Traceback (most recent call last):...ValueError: math domain error>>> gamma(9)40320.0>>> from math import gamma as math_gamma>>> all(.99999999 < gamma(i) / math_gamma(i) <= 1.000000001... for i in range(1, 50))True>>> gamma(-1)/math_gamma(-1) <= 1.000000001Traceback (most recent call last):...ValueError: math domain error>>> gamma(3.3) - math_gamma(3.3) <= 0.00000001True"""if num <= 0:raise ValueError("math domain error")return quad(integrand, 0, inf, args=(num))[0]def integrand(x: float, z: float) -> float:return math.pow(x, z - 1) * math.exp(-x)if __name__ == "__main__":from doctest import testmodtestmod()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。