The java.lang.StrictMath.log1p() is an in-built method in Java which is used to accept a double value as argument and returns the natural logarithm of the sum of the argument and 1.
public static double log1p(double x)
Parameters: The function accepts a double value x as parameter and calculates the natural algorithm of (1+x).
Return Values: This method returns the value ln(1+x). The result of log1p(x) is almost as close as the actual result of ln(1 + x) for small values x than the floating-point evaluation of log(1.0+x).
Following cases are considered :
- The function returns positive infinity if the argument is positive infinity.
- The function returns negative infinity for negative infinty.
- The function returns NaN if the argument is NaN or less than -1.
- The function returns zero with the sign same as that of the argument if the argument is zero.
Input : 2018.0 Output : 7.610357618312838 Input : -4743.0 Output : NaN
Below programs illustrate the working of java.lang.StrictMath.log1p() function:
Program 1: In this program, finite and non-zero argument is passed.
Natural Logarithm of 2019.00567 is 7.610360426629845 Natural Logarithm of 100000.0 is 11.512925464970229
Program 2: In this program, infinite and negative arguments are passed.
Natural Logarithm of Infinity is Infinity Natural Logarithm of -4742.0 is NaN
- StrictMath tan() Method in Java
- StrictMath log() Method In Java
- StrictMath pow() Method in Java
- StrictMath sin() Method in Java
- StrictMath exp() Method in Java
- StrictMath sqrt() Method in Java
- StrictMath tanh() Method in Java
- StrictMath nextUp() Method in Java
- StrictMath fma() method in Java with Examples
- StrictMath signum() Method in Java
- StrictMath cos() Method in Java with Examples
- StrictMath rint() Method in Java
- StrictMath round() method in Java
- StrictMath nextDown() Method in Java
- StrictMath toRadians() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.