\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0224723957348866195:\\
\;\;\;\;\frac{1}{\frac{\sin x}{1 \cdot 1 - \cos x \cdot \cos x} \cdot \left(1 + \cos x\right)}\\
\mathbf{elif}\;x \le 0.0255308872267180458:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\sin x}{\log \left(e^{1 - \cos x}\right)}}\\
\end{array}double code(double x) {
return ((1.0 - cos(x)) / sin(x));
}
double code(double x) {
double temp;
if ((x <= -0.02247239573488662)) {
temp = (1.0 / ((sin(x) / ((1.0 * 1.0) - (cos(x) * cos(x)))) * (1.0 + cos(x))));
} else {
double temp_1;
if ((x <= 0.025530887226718046)) {
temp_1 = ((0.041666666666666664 * pow(x, 3.0)) + ((0.004166666666666667 * pow(x, 5.0)) + (0.5 * x)));
} else {
temp_1 = (1.0 / (sin(x) / log(exp((1.0 - cos(x))))));
}
temp = temp_1;
}
return temp;
}




Bits error versus x
Results
| Original | 30.6 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.02247239573488662Initial program 1.0
rmApplied clear-num1.0
rmApplied flip--1.4
Applied associate-/r/1.4
if -0.02247239573488662 < x < 0.025530887226718046Initial program 59.8
Taylor expanded around 0 0.0
if 0.025530887226718046 < x Initial program 0.9
rmApplied clear-num0.9
rmApplied add-log-exp1.1
Applied add-log-exp1.1
Applied diff-log1.3
Simplified1.1
Final simplification0.6
herbie shell --seed 2020053
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))