简体   繁体   English

如何用Java编写此公式?

[英]How To Code this formula in Java?

I have tried to represent this formula in Java but the values are not correct maybe I have some issue transforming the formula to code. 我尝试用Java表示此公式,但是值不正确,也许我在将公式转换为代码时遇到了问题。

式

private double getFactor(int y) {
    double factor = 10 * Math.pow(3, logOfBase(2, 10 + Math.pow(y, 3)));
    return factor;
}

public double logOfBase(int base, double num) {
    return Math.log(num) / Math.log(base);
}

What about splitting it into more parts: 将其分成更多部分呢:

double temp = (double)10 + Math.pow(0, 3); // 0 = y
double factor = 10 * Math.pow(Math.log(temp), 3); //Math.log - Returns the natural logarithm (base e) of a double value

System.out.println(String.valueOf(factor));

op: 操作:

122.08071553760861 122.08071553760861

我认为您正在寻找的是对数3,而不是对数3的幂。因此,公式应为

double factor = 10 * logOfBase(3, 10 + Math.pow(y, 3)));

To go on Ben Win's for all values of y. 继续y的所有值的本温(Ben Win)。

public double getfactor(int y){
double temp = (double)10 + Math.pow(y, 3); //
double factor = 10 * Math.pow(Math.log(temp), 3); 
return factor;
}

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

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