12 #include "cl_F_tran.h"
14 #include "cln/lfloat.h"
19 const cosh_sinh_t cosh_sinh (const cl_F& x)
22 // Genauigkeit erhöhen,
23 // e := Exponent aus (decode-float x), d := (float-digits x)
24 // falls x=0.0 oder e<=(1-d)/2 liefere (1.0,x)
25 // (denn bei e<=(1-d)/2 ist
26 // 1 <= sinh(x)/x < cosh(x) = 1+x^2/2+... < 1+2^(-d),
27 // also ist cosh(x), auf d Bits gerundet, gleich 1.0
28 // und sinh(x), auf d Bits gerundet, gleich x).
30 // y:=(sinh(x)/x)^2 errechnen,
31 // cosh(x) = sqrt(1+x^2*y) und sinh(x) = x*sqrt(y) errechnen.
32 // falls e>=0: y:=exp(x) errechnen,
33 // (scale-float (+ y (/ y)) -1) und (scale-float (- y (/ y)) -1) bilden.
34 // Genauigkeit wieder verringern.
36 var sintL e = float_exponent(x);
37 if (e < 0) { // Exponent e abtesten
39 if (zerop(x) || (e <= (1-(sintL)float_digits(x))>>1))
40 // e <= (1-d)/2 <==> e <= -ceiling((d-1)/2)
41 return cosh_sinh_t(cl_float(1,x),x);
42 // Rechengenauigkeit erhöhen
46 if (TheLfloat(x)->len >= infty) {
47 var cl_LF xx = extend(x,TheLfloat(x)->len+1);
48 var cl_LF_cosh_sinh_t hyp = cl_coshsinh_ratseries(xx);
50 cln/float.hyp.cosh,x),
55 if (TheLfloat(x)->len >= 585) {
56 // verwende exp(x), schneller als cl_coshsinh_ratseries
57 var cl_LF xx = extend(x,TheLfloat(x)->len+ceiling((uintL)(-e),intDsize));
59 var cl_F y_inv = recip(y);
61 cl_float(scale_float(y + y_inv, -1), x),
62 cl_float(scale_float(y - y_inv, -1), x)
65 var cl_LF xx = The(cl_LF)(cl_F_extendsqrt(x));
66 var cl_LF y = sinhx_naive(xx);
67 var cl_LF z = sqrt(y);
71 cl_float(sqrt(1+y),x), // sqrt(1+y)
76 var cl_F xx = cl_F_extendsqrt(x);
77 var cl_F y = sinhxbyx_naive(xx);
79 cl_float(sqrt(1+square(xx)*y),x), // sqrt(1+x^2*y)
80 cl_float(xx*sqrt(y),x)
84 // e>=0 -> verwende exp(x)
86 var cl_F y_inv = recip(y);
88 scale_float(y+y_inv,-1),
89 scale_float(y-y_inv,-1)