Untitled
unknown
java
2 years ago
622 B
6
Indexable
import static java.lang.Math.log;
import static java.lang.Math.pow;
public class rule_of_doubling {
public static void main(String[] args) {
double temp_min = error_sum(1), optim = 10; //temporary optima
for (double k = 10; k<=100; k+=0.5) {
double sum_error = error_sum(k);
if (sum_error < temp_min) { //updating the optimal figures
temp_min = sum_error;
optim = k;
}
}
System.out.println(optim);
}
public static double error_sum(double k) {
double sum_error = 0;
for (double r = 0.01; r<=0.2; r+=0.005) {
sum_error += pow((log(2)/log(1+r)) - (k/r),2);
}
return sum_error;
}
}Editor is loading...
Leave a Comment