From: Steinar H. Gunderson Date: Sun, 2 Dec 2007 14:44:07 +0000 (+0100) Subject: Optimize the sech²(x) function a bit. X-Git-Url: https://git.sesse.net/?p=foosball;a=commitdiff_plain;h=f7903bdddb48a163a6902e832247d0f97a8ad664 Optimize the sech²(x) function a bit. --- diff --git a/foosrank.cpp b/foosrank.cpp index 67aee58..d295c21 100644 --- a/foosrank.cpp +++ b/foosrank.cpp @@ -32,8 +32,8 @@ static double fac(int x); // sech²(x) static double sech2(double x) { - double c = cosh(x); - return 1.0 / (c*c); + double e = exp(2.0 * x); + return 4.0 * e / ((e+1.0) * (e+1.0)); } #endif