\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0192164982803571076 \lor \neg \left(x \le 0.0203937394598384565\right):\\
\;\;\;\;\frac{\frac{\sqrt{1}}{1}}{\frac{\sin x}{1 - \cos x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\end{array}double code(double x) {
return ((1.0 - cos(x)) / sin(x));
}
double code(double x) {
double temp;
if (((x <= -0.019216498280357108) || !(x <= 0.020393739459838457))) {
temp = ((sqrt(1.0) / 1.0) / (sin(x) / (1.0 - cos(x))));
} else {
temp = ((0.041666666666666664 * pow(x, 3.0)) + ((0.004166666666666667 * pow(x, 5.0)) + (0.5 * x)));
}
return temp;
}




Bits error versus x
Results
| Original | 29.6 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.019216498280357108 or 0.020393739459838457 < x Initial program 0.9
rmApplied clear-num1.0
rmApplied div-inv1.0
Applied associate-/r*1.0
rmApplied *-un-lft-identity1.0
Applied add-sqr-sqrt1.0
Applied times-frac1.0
Applied associate-/l*1.1
Simplified1.0
if -0.019216498280357108 < x < 0.020393739459838457Initial program 59.9
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2020060
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))