log: Represents logarithm, opposite to exponent. E.g:
We read log as the base 3 and the logarithm of 9. The specific calculation method is 3 to the power of 2 to 9, and the logarithm of base 9 to 3 is 2.
lg: The base 10 logarithm is called the common logarithm.
ln: The logarithm based on the irrational number e (e = 2.71828 ...) is called the natural logarithm
Logarithm is the inverse of exponentiation, just as division is the reciprocal of multiplication, and vice versa. This means that the logarithm of a number is an index that must produce another fixed number (base). In simple cases, the log count factor in the multiplier. More generally, powers allow any positive real number to be raised to any actual power, always producing a positive result, so the logarithm can be calculated for any two positive real numbers b and x where b is not equal to 1.
If the power of x of a is equal to N (a> 0, and a is not equal to 1), then the number x is called the logarithm of N based on a, and is written as x = logₐN. Among them, a is called the base of the logarithm and N is called the true number.
1. Seeking lg
java.lang.Math @Contract(pure = true)
public static double log10(double a)
Returns the base 10 logarithm of a double value.
Back to10Logarithm
Special cases:
If the argument is NaN or less than zero, then the result is NaN.
If the parameter is NaN or less0Data, then return NaN
If the argument is positive infinity, then the result is positive infinity.
If the parameter is positive groupless, return positive groupless
If the argument is positive zero or negative zero, then the result is negative infinity.
If the parameter is positive zero or negative zero, the result is negative infinity.
If the argument is equal to 10n for integer n, then the result is n.
If the argument of integer n is equal to10n, the result is n.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
The calculation result must be accurate1ulp range. The result must be semi-monotonic.
2. Find ln
java.lang.Math @Contract(pure = true)
public static double log(double a)
Returns the natural logarithm (base e) of a double value.
returndoubleThe natural logarithm of the type (base e).
Special cases:
If the argument is NaN or less than zero, then the result is NaN.
If the argument is positive infinity, then the result is positive infinity.
If the argument is positive zero or negative zero, then the result is negative infinity.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Params:
a – a value
Returns:
the value ln a, the natural logarithm of a.
The natural logarithm of the value ln a, a.
External annotations:
@org.jetbrains.annotations.Contract(pure = true)
3. Find ln (x + 1)
java.lang.Math @Contract(pure = true)
public static double log1p(double x)
Returns the natural logarithm of the sum of the argument and 1. Note that for small values x, the result of log1p(x) is much closer to the true result of ln(1 + x) than the floating-point evaluation of log(1.0+x).
Return parameters and1The natural logarithm of the sum. Note that for small values x, the result of log1p (x) is better than log (1.0+x) The floating-point evaluation is closer to ln (1+x) The true result.
Special cases:
If the argument is NaN or less than -1, then the result is NaN.
If the argument is positive infinity, then the result is positive infinity.
If the argument is negative one, then the result is negative infinity.
If the argument is zero, then the result is a zero with the same sign as the argument.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
Params:
x – a value
Returns:
the value ln(x + 1), the natural log of x + 1
ln(x + 1),x+1Natural logarithm
Since:
1.5
External annotations:
@org.jetbrains.annotations.Contract(pure = true)
4. Find the logarithm of any base
Implementation principle: change formula

static public double log(double value, int base){
return Math.log(value) / Math.log(base);
}
5. Code example
public static void main(String[] args) {
System.out.println("Math.log==>"+Math.log(-1));
System.out.println("Double.NaN==>"+Double.NaN);
System.out.println("Math.log10(10)==>"+Math.log10(10));
System.out.println("Math.log1p(9)==>"+Math.log1p(9));
System.out.println("Math.log(10)==>"+Math.log(10));
System.out.println("log2 8==>"+log(8,2));
System.out.println("log5 125==>"+log(125, 5));
}
operation result
Math.log==>NaN
Double.NaN==>NaN
Math.log10(10)==>1.0
Math.log1p(9)==>2.302585092994046
Math.log(10)==>2.302585092994046
log2 8==>3.0
log5 125==>3.0000000000000004
| Name | Description |
|---|---|
| LN() | Return the natural logarithm of the argument |
| LOG() | Return the natural logarithm of the first argument |
| LOG10() | Return the base-10 logarithm of the argument |
| LOG2() | Return the base-2 logarithm of the argument |
Reference link: https://dev.mysql.com/doc/refman/5.7/en/mathematical-functions.html#function_log
1.LN(X)
Returns the natural logarithm of X; that is, the base-e logarithm of X. If X is less than or equal to 0.0E0, the function returns NULL and a warning “Invalid argument for logarithm” is reported.
Returns the natural logarithm of X, which is the base e logarithm of X. If X is less than or equal to0.0E0, the function returns a null value, and reports the warning "log parameter is invalid"
mysql> SELECT LN(2);
-> 0.69314718055995
mysql> SELECT LN(-2);
-> NULL
This function is synonymous with LOG(X). The inverse of this function is the EXP() function.
This function is synonymous with LOG (X). The inverse function of this function is the EXP () function.
2.LOG(X), LOG(B,X)
If called with one parameter, this function returns the natural logarithm of X. If X is less than or equal to 0.0E0, the function returns NULL and a warning “Invalid argument for logarithm” is reported.
If called with one parameter, this function returns the natural logarithm of X. If X is less than or equal to0.0E0, then this function returns a null value and reports the warning "Log parameter is invalid".
The inverse of this function (when called with a single argument) is the EXP() function.
The inverse of this function (when called with a single parameter) is the EXP () function.
mysql> SELECT LOG(2);
-> 0.69314718055995
mysql> SELECT LOG(-2);
-> NULL
If called with two parameters, this function returns the logarithm of X to the base B. If X is less than or equal to 0, or if B is less than or equal to 1, then NULL is returned.
If called with two parameters, this function returns the logarithm of X to the base B. If X is less than or equal to0, Or if B is less than or equal to1, Then returnNULL。
mysql> SELECT LOG(2,65536);
-> 16
mysql> SELECT LOG(10,100);
-> 2
mysql> SELECT LOG(1,100);
-> NULL
LOG(B,X) is equivalent to LOG(X) / LOG(B).
LOG (B, X) is equivalent to LOG (X)/LOG(B)。
3.LOG2(X)
Returns the base-2 logarithm of X. If X is less than or equal to 0.0E0, the function returns NULL and a warning “Invalid argument for logarithm” is reported.
Return X2Base logarithm. If X is less than or equal to0.0E0, the function returns a null value and reports the warning "Logarithmic parameter is invalid"
mysql> SELECT LOG2(65536);
-> 16
mysql> SELECT LOG2(-100);
-> NULL
LOG2() is useful for finding out how many bits a number requires for storage. This function is equivalent to the expression LOG(X) / LOG(2).
LOG2 () helps to find out how many bits are needed for a digital storage. This function is equivalent to the expression LOG (X)/LOG(2)。
4.LOG10(X)
Returns the base-10 logarithm of X. If X is less than or equal to 0.0E0, the function returns NULL and a warning “Invalid argument for logarithm” is reported.
Return X10Base logarithm. If X is less than or equal to0.0E0, the function returns a null value and reports the warning "Logarithmic parameter is invalid"
mysql> SELECT LOG10(2);
-> 0.30102999566398
mysql> SELECT LOG10(100);
-> 2
mysql> SELECT LOG10(-100);
-> NULL
LOG10(X) is equivalent to LOG(10,X).
LOG10 (X) is equivalent to LOG (10,X)
Reference documents:
1.java8API
2. Official mysql document: https://dev.mysql.com/doc/refman/5.7/en/mathematical-functions.html#function_log
Java implementation log desensitization Inscription In daily work, log processing is a must-have for every programmer, but in some scenarios customer information is sensitive and requires some fields,...
The installation was successful on the previous blog (Canal confirmed that the startup was successful), and then proceed to the code implementation. Synchronization needs to be running all the time, s...
Official documenthttps://scikit-learn.org/stable/modules/generated/sklearn.metrics.log_loss.html principle Loss of logs, ie log-likelihood loss, also known as logistic loss loss (cross-entropy loss), ...
Test (error is not optimized)...
0. Introduction On the basis of the previous log2, you can now count any log, here we calculate ln 1.LN expression This formula can be obtained according to the final formula。 2. Implementation ...
The log is divided into the main body System Subsystem Module Submodule Logs are classified by severity type Information caveat Error Fatal error The class is called as follows The source code ...
Get the user IP System log notes The method of using custom annotations to identify a...
Foreword: The most important part of the project refactoring is log information storage and error information positioning. Here is a summary of the ideas of our project team leaders. Java logs are rou...
Java full link log implementation 1. What is a full link log 2. Actual project structure Three, concrete realization 3.1 The effect to be achieved 3.2 Implementation scheme web filter Dubbo filter Fou...