Java Reference
In-Depth Information
where x is the number whose logarithm you want, n is any desired base, and e is the natural
logarithm base. I have a simple LogBase class containing code that implements this function-
ality:
// LogBase.java
public
public static
static double
double log_base ( double
double base , double
double value ) {
return
return Math . log ( value ) / Math . log ( base );
}
Discussion
My log_base function allows you to compute logs to any positive base. If you have to per-
form a lot of logs to the same base, it is more efficient to rewrite the code to cache the
log(base) once. Here is an example of using log_base :
// LogBaseUse.java
public static void main(String argv[]) {
double d = LogBase.log_base(10, 10000);
System.out.println("log10(10000) = " + d);
}
C:> java numbers.LogBaseUse
log10(10000) = 4.0
Multiplying Matrices
Problem
You need to multiply a pair of two-dimensional arrays, as is common in mathematical and
engineering applications.
Search WWH ::




Custom Search