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




Bits error versus x
Results
| Original | 30.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.004241983975724705Initial program 0.9
rmApplied add-exp-log0.9
rmApplied pow10.9
Applied log-pow0.9
Applied exp-prod0.9
Simplified0.9
if -0.004241983975724705 < (/ (- 1.0 (cos x)) (sin x)) < 0.0002160397078343796Initial program 59.9
Taylor expanded around 0 0.1
if 0.0002160397078343796 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.0
rmApplied flip3--1.1
Simplified1.1
rmApplied flip-+1.1
Applied associate-*r/1.1
Final simplification0.6
herbie shell --seed 2020058
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))