PHP and asinh() on Windows
Published by Cam November 15th, 2007 in Fixes, Geometry, Overlays, PHP, ProjectionsIn the last few weeks we’ve seen an explosion of people complaining about the lack of asinh() on the Windows version of PHP. We use the asinh() function extensively in Chapter 7 for the custom tile overlays. Admittedly, we didn’t test any of the code against windows versions of PHP (we’re LAMP folks), so until the middle of September when Stuart contacted us to ask a question we had no idea about the problem.
So far the solution isn’t great. User comments from the PHP.net documentation suggest:
if (!function_exists("asinh")) {
function asinh($z) {
return log($z + sqrt($z^2 +1));
}
}
However, due to limitations in float-point computation, the accuracy of this alternative function breaks down at higher zoom levels, especially close to the equator. At least two alternatives exist. Our reader Stuart suggests an arbitrary fudge factor of 1.65:
if (!function_exists("asinh")) {
function asinh($z) {
return log($z + sqrt(($z^2) + 1 ), 1.65);
}
}
Another reader of our book, Allan, posted a comment at PHP.net suggests using ln rather than log:
if (!function_exists("asinh")) {
function asinh($x)
{
return ln($x + sqrt(1 + pow($x, 2)));
}
function ln($x)
{
return $x = log($x)/log(M_E);
}
}
We haven’t got a Windows box to test these out on, but here’s what they look like on Linux. Anyone got a suggestion for us?
Aside that isn’t worth it’s own post…
There have been lots of developments in the GoogleMaps world, hopefully you’ve been following the official Google Maps API Blog for news like that. The books continue to get rave reviews and both are still excellent primers for digging into the world of maps. Very little of the code in the books is wrong or obsolete even after more than a year on the shelves. For a technology book we’re pretty proud about that. Sure, there are new functions in the API that handle some of the work for you that didn’t exist when we wrote the book, but our methods work just as well and often take some of the burden off of the user’s browser… If you agree, please consider writing a review on Amazon.com for us. Thanks in advance!


Get emailed automatically
Today I’ve posted the solution on php.net documentation about asinh(x)using ln rather than log, as described on this post.
http://php.net/manual/en/function.asinh.php
It’s worked great with example of chapter 7 (FCC structure) on Windows Plataform and on Linux Too in many zoom levels!
You can see the comparative results between asinh(x) linux native, asinh(x) using log(x) and asinh(x) using ln(x)opening this worksheet http://www.mavadesign.com.br/allan/asinh(x).xls
The error of this implemented function is zero
Allan Patrick Engel
CURITIBA - PARANÁ - BRASIL