Friday, October 31, 2008

IBM Article: Java's new Math

I saw an article about how Java beefed up its java.lang.Math:

http://www.ibm.com/developerworks/java/library/j-math1/index.html?ca=drs-

The author agrees that the Pythagorean Theorem is important, "...that this equation shows up a lot more than in just right triangles". Um, those things that the author listed, are right triangles.

I get OFFENDED by this statement: "The naive approach (for hypotenuse) would look something like this"

public static double hypot(double x, double y){
return Math.sqrt (x*x + y*y);
}

There is nothing naive about it!
The author showed some hardcore C code for Java in bit shifting. I prefer the "naive" approach.

The author griped about log vs. ln:

"Sadly, the Java language's (and C's and Fortran's and Basic's) natural logarithm function is misnamed as log(). "

Um, computer science tends to call the natural logarithm "log". Because common logarithm is of no use in computer science. After all, common logarithm and natural logarithm differ by a constant, so it doesn't matter in order of complexity (yes, that big O notation). log x = ln(x)/ln(10). (go ahead, punch in calculator if you don't believe me).


I see little use of defining hyperbolic trig functions. They are defined in terms of the exponential function. how often does anyone need hyperbolic trig functions?

There is no need to define cubic roots either. x1/3 = exp( 1/3 ln (x) ). So all you need are ln and exp.
How often do anyone use cube root?

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.