this repo has no description
1
2//
3// by Ian Ollmann
4//
5// based on MathLib v3
6//
7// Copyright � 2005, Apple Computer Inc. All rights reserved.
8//
9
10
11#include <math.h>
12#include <xmmLibm_prefix.h>
13
14double acosh( double x )
15{
16 static const double ln2 = 0x1.62e42fefa39ef358p-1; //ln(2)
17
18 if( x != x ) return x + x;
19 if( x < 1.0 )
20 {
21 SET_INVALID_FLAG();
22 return __builtin_nan( "" );
23 }
24
25 double xm1 = x - 1.0;
26
27 if( x < 1.25 )
28 return log1p( xm1 + sqrt( xm1 + xm1 + xm1 * xm1 ));
29
30 if( x < 0x1.0p27 ) //1/sqrt(negative epsilon )
31 return log( x + x - 1.0 / ( x + sqrt( x * x -1.0 )));
32
33 return log( x ) + ln2;
34}
35
36long double acoshl( long double x )
37{
38 static const long double ln2 = 0x1.62e42fefa39ef358p-1L; //ln(2)
39
40 if( x != x ) return x + x;
41 if( x < 1.0L )
42 {
43 SET_INVALID_FLAG();
44 return __builtin_nanl( "" );
45 }
46
47 long double xm1 = x - 1.0L;
48
49
50 if( x < 1.25L )
51 return log1pl( xm1 + sqrtl( xm1 + xm1 + xm1 * xm1 ));
52
53 if( x < 0x1.0p32 ) //1/sqrt(negative epsilon )
54 return logl( x + x - 1.0L / ( x + sqrtl( x * x -1.0L )));
55
56 return logl( x ) + ln2;
57}
58
59