简体   繁体   English

数学:我们什么时候使用对数,它是如何工作的?

[英]Math: when do we use logarithms and how does it work?

I were solving:我正在解决:

We know the content of the evaporator (content in ml), the percentage of foam or gas lost every day (evap_per_day) and the threshold (threshold) in percentage beyond which the evaporator is no longer useful.我们知道蒸发器的含量(以毫升为单位的含量)、每天损失的泡沫或气体百分比 (evap_per_day) 以及蒸发器不再有用的百分比阈值(阈值)。 All numbers are strictly positive.所有数字都是严格的正数。 The program reports the nth day (as an integer) on which the evaporator will be out of use.程序报告蒸发器将停止使用的第 n 天(作为整数)。

My solution with recursion:我的递归解决方案:

if (content > (initialContent / 100) * threshold) {
   double postContent = content - (content / 100) * evap_per_day;
   iterations++;
   return recursiveEvaporator(postContent, evap_per_day, threshold, initialContent, iterations);
}

But then I found more sophisticated solution: return (int)Math.ceil(Math.log(threshold / 100.0) / Math.log(1.0 - evap_per_day / 100.0));但后来我发现了更复杂的解决方案: return (int)Math.ceil(Math.log(threshold / 100.0) / Math.log(1.0 - evap_per_day / 100.0)); Could you please explain me how does logarithms work here and why we choose natural logarithm?你能解释一下对数在这里是如何工作的以及我们为什么选择自然对数吗?

  • First of all you have to obtain a clear image of e , that is the base of the natural logarithm.首先,您必须获得e的清晰图像,即自然对数的底数。 e - is constant that represents approximation of (1 + 1/n)^n that we call for when speaking about constant growth e - 是常数,表示我们在谈论持续增长时所要求的(1 + 1/n)^n近似值
    持续增长

    We see that newly appeared "addition" participated in further exponentiation.Roughly speaking: e^x is our income after x, where x is t*r (t-time; r-rate)我们看到新出现的“加法”参与了进一步的求幂。 粗略地说:e^x 是我们在 x 之后的收入,其中 x 是 t*r (t-time; r-rate)

    • ln(y) is a reverse operation, we are aimed to know the time over rate we have to spend waiting for y income. ln(y) 是一个反向操作,我们的目标是知道等待 y 收入所花费的时间。

Bringing back the subject of your question ln(threshold) - is t*r(time * rate) ln(1 - evap_per_day) - is at*r to evoparate 90% !but not initial, again we need ln because 90% is constantly decreasing and we chould include it into account.回到你问题的主题ln(threshold) - 是 t*r(time * rate) ln(1 - evap_per_day) - 是 at*r 来 evoparate 90% !但不是初始,我们再次需要ln因为 90% 是不断减少,我们应该将其考虑在内。 We divide a product of ln(threshold) by ln(1 - evap_per_day) to get know the time.我们将 ln(threshold) 的乘积除以 ln(1 - evap_per_day) 来了解时间。

So the correct solution is: (int)Math.ceil(Math.log(threshold / 100.0) / (ln(1.0 - evap_per_day / 100.0))所以正确的解决方案是: (int)Math.ceil(Math.log(threshold / 100.0) / (ln(1.0 - evap_per_day / 100.0))

This is a case of using exponential decay and solving for time这是一个使用指数衰减并求解时间的案例

The Exponential decay formula is A = A_o(1 - r)^t where A is the final quantity, A_o is the inital quantity, r is the rate of decay and t is the time.For this question we want to know the number of days until the intial amount is at or below a threshold percentage of the initail amount, evaperating at a cetain percentage per day.指数衰减公式为 A = A_o(1 - r)^t 其中 A 是最终量,A_o 是初始量,r 是衰减率,t 是时间。对于这个问题,我们想知道天,直到初始量等于或低于初始量的阈值百分比,每天蒸发一定百分比。 We can rewrite the equation as so: (using the percent values for threshold and evapPerDay to make explaination easier) A_o(threshold) = A_o( 1 - evapPerDay)^t我们可以将等式重写为:(使用阈值和 evapPerDay 的百分比值使解释更容易) A_o(threshold) = A_o( 1 - evapPerDay)^t

simplifies to: threshold = (1 - evapPerDay)^t简化为:阈值 = (1 - evapPerDay)^t

now we use logs to solve for t现在我们使用对数来求解 t

log(threshold) = log((1- evapPerDay)^t)日志(阈值)=日志((1- evapPerDay)^ t)

use one of the laws of logs to move the t使用原木定律之一移动 t

log(threshold) = t(log(1-evapPerDay))日志(阈值)= t(日志(1-evapPerDay))

solve for t求解 t

log(threshold)/log(1-evapPerDay) = t日志(阈值)/日志(1-evapPerDay)= t

Use ceiling to round up.使用天花板四舍五入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM