\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0236105927013185481:\\
\;\;\;\;\frac{1}{\sin x} - \frac{\cos x}{\sin x}\\
\mathbf{elif}\;x \le 0.0199371016091038876:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{1}{\frac{\sin x}{1 - \cos x}}}\right)\\
\end{array}double f(double x) {
double r63930 = 1.0;
double r63931 = x;
double r63932 = cos(r63931);
double r63933 = r63930 - r63932;
double r63934 = sin(r63931);
double r63935 = r63933 / r63934;
return r63935;
}
double f(double x) {
double r63936 = x;
double r63937 = -0.023610592701318548;
bool r63938 = r63936 <= r63937;
double r63939 = 1.0;
double r63940 = sin(r63936);
double r63941 = r63939 / r63940;
double r63942 = cos(r63936);
double r63943 = r63942 / r63940;
double r63944 = r63941 - r63943;
double r63945 = 0.019937101609103888;
bool r63946 = r63936 <= r63945;
double r63947 = 0.041666666666666664;
double r63948 = 3.0;
double r63949 = pow(r63936, r63948);
double r63950 = r63947 * r63949;
double r63951 = 0.004166666666666667;
double r63952 = 5.0;
double r63953 = pow(r63936, r63952);
double r63954 = r63951 * r63953;
double r63955 = 0.5;
double r63956 = r63955 * r63936;
double r63957 = r63954 + r63956;
double r63958 = r63950 + r63957;
double r63959 = 1.0;
double r63960 = r63939 - r63942;
double r63961 = r63940 / r63960;
double r63962 = r63959 / r63961;
double r63963 = exp(r63962);
double r63964 = log(r63963);
double r63965 = r63946 ? r63958 : r63964;
double r63966 = r63938 ? r63944 : r63965;
return r63966;
}




Bits error versus x
Results
| Original | 30.1 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.023610592701318548Initial program 0.9
rmApplied div-sub1.1
if -0.023610592701318548 < x < 0.019937101609103888Initial program 59.7
Taylor expanded around 0 0.0
if 0.019937101609103888 < x Initial program 0.8
rmApplied add-log-exp0.9
rmApplied clear-num1.0
Final simplification0.5
herbie shell --seed 2020057
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))