While I'm using truncating in this method, it is somewhere wrong as in picture
public static List<Double> interp(DoubleUnaryOperator f, double l, double u, int n) {
double d = (u - l)/n;
List<Double> result = new ArrayList<>(n);
double net = f.applyAsDouble(l);
result.add(net);
int i = 0;
while(i+1 < n){
result.add(Math.floor(f.applyAsDouble(l + d)*100)/100);
l += d;
i++;
}
return result;
}
Who know how to truncate correclty? P.S. its important for the number be in two decimal places.