
package com.logicbig.example.math;
public class Log1pExample {
public static void main(String... args) {
findLog1p(7);
findLog1p(35.50);
findLog1p(-1);
findLog1p(-23.1);
findLog1p(0);
findLog1p(Double.POSITIVE_INFINITY);
}
private static void findLog1p(double x) {
double result = Math.log1p(x);
System.out.printf("Math.log1p(%s) = %s%n", x, result);
}
}
Output
Math.log1p(7.0) = 2.0794415416798357
Math.log1p(35.5) = 3.597312260588446
Math.log1p(-1.0) = -Infinity
Math.log1p(-23.1) = NaN
Math.log1p(0.0) = 0.0
Math.log1p(Infinity) = Infinity