12 #include "cl_F_tran.h"
14 #include "cl_lfloat.h"
17 const cl_F sinh (const cl_F& x)
20 // Genauigkeit erhöhen,
21 // e := Exponent aus (decode-float x)
22 // falls e<0: (sinh(x)/x)^2 errechnen, Wurzel ziehen, mit x multiplizieren.
23 // falls e>=0: y:=exp(x) errechnen, (scale-float (- y (/ y)) -1) bilden.
25 if (float_exponent(x) < 0) { // Exponent e abtesten
27 // Rechengenauigkeit erhöhen
31 if (TheLfloat(x)->len >= infty) {
32 var cl_LF xx = extend(x,TheLfloat(x)->len+1);
33 var cl_LF_cosh_sinh_t hyp = cl_coshsinh_ratseries(xx);
34 return cl_float(hyp.sinh,x);
37 if ((TheLfloat(x)->len >= 500)
38 && (float_exponent(x) > (-(sintL)float_digits(x))>>1)) {
39 // verwende exp(x), schneller als cl_coshsinh_ratseries
40 // (aber nur bei 0 > e > -d/2, denn wir müssen, um
41 // Auslöschung zu verhindern, |e| Bits dazunehmen)
42 var cl_LF xx = extend(x,TheLfloat(x)->len+ceiling((uintL)(-float_exponent(x)),intDsize));
44 var cl_F z = scale_float(y - recip(y), -1); // (/ (- y (/ y)) 2)
47 var cl_LF xx = The(cl_LF)(cl_F_extendsqrt(x));
48 // Wurzel aus sinh(x)^2 bilden
49 var cl_LF z = sqrt(sinhx_naive(xx));
55 var cl_F xx = cl_F_extendsqrt(x);
56 // Wurzel aus (sinh(x)/x)^2 mit x multiplizieren und wieder runden
57 return cl_float(sqrt(sinhxbyx_naive(xx))*xx,x);
60 // e>=0 -> verwende exp(x)
62 return scale_float(y - recip(y), -1); // (/ (- y (/ y)) 2)
66 // Timings of the two algorithms, on an i486 33 MHz, running Linux,
67 // applied to x = sqrt(2)-1 = 0.414...
77 // ==> ratseries faster for N >= 1300.