From f7903bdddb48a163a6902e832247d0f97a8ad664 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 2 Dec 2007 15:44:07 +0100 Subject: [PATCH] =?utf8?q?Optimize=20the=20sech=C2=B2(x)=20function=20a=20?= =?utf8?q?bit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- foosrank.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.39.2