\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.022467842987435108 \lor \neg \left(x \le 0.019167687208925581\right):\\
\;\;\;\;\log \left(e^{\frac{1}{\frac{\sin x}{1 - \cos x}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{24}, {x}^{3}, \mathsf{fma}\left(\frac{1}{240}, {x}^{5}, \frac{1}{2} \cdot x\right)\right)\\
\end{array}double code(double x) {
return ((double) (((double) (1.0 - ((double) cos(x)))) / ((double) sin(x))));
}
double code(double x) {
double VAR;
if (((x <= -0.022467842987435108) || !(x <= 0.01916768720892558))) {
VAR = ((double) log(((double) exp(((double) (1.0 / ((double) (((double) sin(x)) / ((double) (1.0 - ((double) cos(x))))))))))));
} else {
VAR = ((double) fma(0.041666666666666664, ((double) pow(x, 3.0)), ((double) fma(0.004166666666666667, ((double) pow(x, 5.0)), ((double) (0.5 * x))))));
}
return VAR;
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.022467842987435108 or 0.01916768720892558 < x Initial program 0.9
rmApplied add-log-exp1.1
rmApplied clear-num1.1
if -0.022467842987435108 < x < 0.01916768720892558Initial program 59.9
Taylor expanded around 0 0.0
Simplified0.0
Final simplification0.6
herbie shell --seed 2020114 +o rules:numerics
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))