在设定范围内计算指数极限的脚本 [英] Script for working out exponential limit within a set range

查看:57
本文介绍了在设定范围内计算指数极限的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在B列上方的图像中,A1的倍数,C列为C = C + B(向下移动各行)

In the image above column B is multiples of A1 and column C is C = C + B (working down the rows)

我得出结论,为了使C在20行中为50,A1必须为0.2631579,但我希望能够将其简化为一个将返回列表的函数:list = exp(50,20)

I worked out that in order for C for be 50 in 20 rows A1 has to be 0.2631579 but I'd like to be able to simplify that to a function that will return a list: list = exp(50, 20).

我不确定此类脚本的术语,因此事前研究并没有带来任何遗憾.

I'm not sure about the terminology of such a script so researching beforehand didn't really bring anything up sorry.

推荐答案

根据您的问题陈述,我们知道:

Well based on your problem statement, we know that:

B n =(n-1)× a ;和 C n =(n-1)times; n× a/2 (其中 a A 1 ).

Bn=(n-1)×a; and Cn=(n-1)×n×a/2 (here a is the value for A1).

所以我们只需要为 C 20 = 50 求解 a .或更纯正的: C n = m .这很简单:a = 2×m/(n×(n-1)).

So we only have to solve a for C20=50. Or more genic: Cn=m. This is simply: a = 2×m/(n×(n-1)).

所以功能很简单:

def find_threshold(m,n):
    return 2.0*m/(n*(n-1))

对于您的示例输入,下限是:

For your sample input, the lower bound is:

>>> find_threshold(50,20)
0.2631578947368421

如果将此值插入 Excel 工作表中,则将获得50(尽管可能会有小的四舍五入误差).假设我们假设对数字的计算是在恒定时间内完成的,那么此脚本也可以在恒定时间内运行( O(1)),因此它的运行速度非常快(即使行数等巨大).

If you plug in this value in the Excel sheet, you will obtain 50 (although there can be small rounding errors). Given we assume calculations on the numbers are done in constant time, this script works in constant time as well (O(1)) so it is quite fast (even if the row number, etc. would be huge).

这篇关于在设定范围内计算指数极限的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆