amath  1.6.2
Simple command line calculator
acosh.c File Reference
#include "prim.h"
#include "math.h"
Include dependency graph for acosh.c:

Go to the source code of this file.

Functions

double acosh (double x)
 Inverse hyperbolic cosine function. More...
 

Variables

static const double one = 1.0
 
static const double ln2 = 6.93147180559945286227e-01
 

Function Documentation

double acosh ( double  x)

Inverse hyperbolic cosine function.

Version
1.3
Date
95/01/18
Method :
 Based on
    acosh(x) = log [ x + sqrt(x*x-1) ]
 we have
    acosh(x) := log(x)+ln2, if x is large; else
    acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
    acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
Special cases:
 acosh(x) is NaN with signal if x<1.
 acosh(NaN) is NaN without signal.

Definition at line 75 of file acosh.c.

References ln2, log1p(), one, and sqrt().

Referenced by RealNumber::HypArcCosine(), and RealNumber::HypArcSecant().

76 {
77  double t;
78  sword hx, lx;
79  GET_HIGH_WORD(hx,x);
80  GET_LOW_WORD(lx,x);
81 
82  if(hx<0x3ff00000) { /* x < 1 */
83  return (x-x)/(x-x);
84  } else if(hx >=0x41b00000) { /* x > 2**28 */
85  if(hx >=0x7ff00000) { /* x is inf of NaN */
86  return x+x;
87  } else
88  return log(x)+ln2; /* acosh(huge)=log(2x) */
89  } else if(((hx-0x3ff00000)|lx)==0) {
90  return 0.0; /* acosh(1) = 0 */
91  } else if (hx > 0x40000000) { /* 2**28 > x > 2 */
92  t=x*x;
93  return log(2.0*x-one/(x+sqrt(t-one)));
94  } else { /* 1<x<2 */
95  t = x-one;
96  return log1p(t+sqrt(2.0*t+t*t));
97  }
98 }
static const double one
Definition: acosh.c:48
#define GET_HIGH_WORD(i, d)
Get the more significant 32 bit int from a double.
Definition: prim.h:165
double log1p(double x)
Definition: log1p.c:125
#define GET_LOW_WORD(i, d)
Get the less significant 32 bit int from a double.
Definition: prim.h:176
signed int sword
32 bit signed integer.
Definition: prim.h:107
double sqrt(double x)
Square root function.
Definition: sqrt.c:127
double log(double x)
Natural logarithm function (base e).
Definition: log.c:118
static const double ln2
Definition: acosh.c:49

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const double ln2 = 6.93147180559945286227e-01
static

Definition at line 49 of file acosh.c.

Referenced by acosh().

const double one = 1.0
static

Definition at line 48 of file acosh.c.

Referenced by acosh().