我写了this function在 python 中:
import math
def radical(a, b, k):
return (1-((a**2-b**2)/a**2)*(math.sin(math.pi*(2*k-1)/180))**2)**.5
def f(a, b):
sigma = 0
for k in range(1,180/4):
sigma = sigma + radical(a, b, k)
return 8*a*math.sin(math.pi/180)*sigma
print f(25.,35.)
当我在 Wolphramapha 和 Maple 中计算这个函数时,我将得到 189.797 但使用 python I will get 184.91089913 我的程序有什么问题?
最佳答案
关于python - Python 中的浮点精度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13650155/