3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <gsl/gsl_math.h>
23 #include <gsl/gsl_machine.h>
26 gsl_acosh (const double x)
28 if (x > 1.0 / GSL_SQRT_DBL_EPSILON)
30 return log (x) + M_LN2;
34 return log (2 * x - 1 / (sqrt (x * x - 1) + x));
39 return log1p (t + sqrt (2 * t + t * t));
52 gsl_asinh (const double x)
55 double s = (x < 0) ? -1 : 1;
57 if (a > 1 / GSL_SQRT_DBL_EPSILON)
59 return s * (log (a) + M_LN2);
63 return s * log (2 * a + 1 / (a + sqrt (a * a + 1)));
65 else if (a > GSL_SQRT_DBL_EPSILON)
68 return s * log1p (a + a2 / (1 + sqrt (1 + a2)));
77 gsl_atanh (const double x)
80 double s = (x < 0) ? -1 : 1;
88 return (x < 0) ? GSL_NEGINF : GSL_POSINF;
92 return s * 0.5 * log1p (2 * a / (1 - a));
94 else if (a > GSL_DBL_EPSILON)
96 return s * 0.5 * log1p (2 * a + 2 * a * a / (1 - a));