\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02298820551471121229059058066468423930928 \lor \neg \left(x \le 0.01805643764531137188122933423528593266383\right):\\
\;\;\;\;\left(1 - \cos x\right) \cdot {\left(\sin x\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot x + \left({x}^{3} \cdot \frac{1}{24} + {x}^{5} \cdot \frac{1}{240}\right)\\
\end{array}double f(double x) {
double r31588 = 1.0;
double r31589 = x;
double r31590 = cos(r31589);
double r31591 = r31588 - r31590;
double r31592 = sin(r31589);
double r31593 = r31591 / r31592;
return r31593;
}
double f(double x) {
double r31594 = x;
double r31595 = -0.022988205514711212;
bool r31596 = r31594 <= r31595;
double r31597 = 0.018056437645311372;
bool r31598 = r31594 <= r31597;
double r31599 = !r31598;
bool r31600 = r31596 || r31599;
double r31601 = 1.0;
double r31602 = cos(r31594);
double r31603 = r31601 - r31602;
double r31604 = sin(r31594);
double r31605 = -1.0;
double r31606 = pow(r31604, r31605);
double r31607 = r31603 * r31606;
double r31608 = 0.5;
double r31609 = r31608 * r31594;
double r31610 = 3.0;
double r31611 = pow(r31594, r31610);
double r31612 = 0.041666666666666664;
double r31613 = r31611 * r31612;
double r31614 = 5.0;
double r31615 = pow(r31594, r31614);
double r31616 = 0.004166666666666667;
double r31617 = r31615 * r31616;
double r31618 = r31613 + r31617;
double r31619 = r31609 + r31618;
double r31620 = r31600 ? r31607 : r31619;
return r31620;
}




Bits error versus x
Results
| Original | 30.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.022988205514711212 or 0.018056437645311372 < x Initial program 0.9
rmApplied *-un-lft-identity0.9
Applied *-un-lft-identity0.9
Applied times-frac0.9
Simplified0.9
rmApplied add-log-exp1.0
rmApplied div-inv1.1
Applied exp-prod1.3
Applied log-pow1.2
Simplified1.0
rmApplied inv-pow1.0
if -0.022988205514711212 < x < 0.018056437645311372Initial program 59.8
rmApplied *-un-lft-identity59.8
Applied *-un-lft-identity59.8
Applied times-frac59.8
Simplified59.8
rmApplied add-log-exp59.8
rmApplied div-inv59.9
Applied exp-prod59.9
Applied log-pow59.9
Simplified59.9
Taylor expanded around 0 0.0
Simplified0.0
Final simplification0.5
herbie shell --seed 2019195
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))