拉马努金无穷根式是印度数学家拉马努金(Srinivasa Ramanujan)于20世纪初提出的。
f(x) = sqrt(1 + (x + 1) * f(x + 1))
上面的函数是一个递归式,下面用Python编程计算该函数的值。
Python代码:
import math
class Ramanujan(object):
def sum(self, d, md):
if d > md:
return 0
return math.sqrt(1 + (d + 1) * self.sum(d + 1, md))
使用matplotlib画出x取值范围[1, 50]时的散点图:
Python代码:
import matplotlib.pyplot as plt
r = Ramanujan()
size = 50
x = list(range(1, size + 1))
y = map(r.sum, [1] * size, x)
plt.title("Ramanujan infinite radicals")
plt.xlabel("x")
plt.ylabel("f(x)")
plt.scatter(x, y)
plt.show()
观察可以发现函数值最后收敛于3,证明过程可以参阅:http://math.stackexchange.com/questions/7204/evaluating-the-nested-radical-sqrt1-2-sqrt1-3-sqrt1-cdots
本文链接:https://bookshadow.com/weblog/2016/07/03/calculate-ramanujan-infinite-radicals/
请尊重作者的劳动成果,转载请注明出处!书影博客保留对文章的所有权利。
如果这篇博客对你有帮助,请支持书影博客
你的捐赠将用于服务器与域名费用,帮助免费技术内容持续更新。
支付宝
微信
建议金额:¥5 / ¥10 / ¥20 / ¥50(扫码后自行输入)
兄弟,交换链接吗?