\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.024735187037949399:\\
\;\;\;\;\frac{{e}^{\left(\log \left(\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}\right)\right)}}{\sin x}\\
\mathbf{elif}\;x \le 0.0203308535179141901:\\
\;\;\;\;\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{{e}^{\left(\log \left(1 - \cos x\right)\right)}}{\sin x}}\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.0247351870379494)) {
VAR = ((double) (((double) pow(((double) M_E), ((double) log(((double) (((double) (((double) pow(1.0, 3.0)) - ((double) pow(((double) cos(x)), 3.0)))) / ((double) (((double) (((double) cos(x)) * ((double) (((double) cos(x)) + 1.0)))) + ((double) (1.0 * 1.0)))))))))) / ((double) sin(x))));
} else {
double VAR_1;
if ((x <= 0.02033085351791419)) {
VAR_1 = ((double) (((double) (0.041666666666666664 * ((double) pow(x, 3.0)))) + ((double) (((double) (0.004166666666666667 * ((double) pow(x, 5.0)))) + ((double) (0.5 * x))))));
} else {
VAR_1 = ((double) log(((double) exp(((double) (((double) pow(((double) M_E), ((double) log(((double) (1.0 - ((double) cos(x)))))))) / ((double) sin(x))))))));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x
Results
| Original | 30.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.0247351870379494Initial program 0.9
rmApplied add-exp-log0.9
rmApplied pow10.9
Applied log-pow0.9
Applied exp-prod1.0
Simplified1.0
rmApplied flip3--1.1
Simplified1.1
if -0.0247351870379494 < x < 0.02033085351791419Initial program 59.9
Taylor expanded around 0 0.0
if 0.02033085351791419 < x Initial program 0.9
rmApplied add-exp-log0.9
rmApplied pow10.9
Applied log-pow0.9
Applied exp-prod0.9
Simplified0.9
rmApplied add-log-exp1.1
Final simplification0.5
herbie shell --seed 2020120
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))