]> git.sesse.net Git - foosball/commitdiff
Optimize the sech²(x) function a bit.
authorSteinar H. Gunderson <sesse@debian.org>
Sun, 2 Dec 2007 14:44:07 +0000 (15:44 +0100)
committerSteinar H. Gunderson <sesse@debian.org>
Sun, 2 Dec 2007 14:44:07 +0000 (15:44 +0100)
foosrank.cpp

index 67aee581cbe05f2d8d2064d5e997ab262453706b..d295c212ed04187a5ba42995a2d2a5852bf65150 100644 (file)
@@ -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