\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02763831198473910497059868873748200712726:\\
\;\;\;\;\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)\\
\mathbf{elif}\;x \le 0.02784500067586437310751534823793917894363:\\
\;\;\;\;\left(0.008333333333333331482961625624739099293947 \cdot {x}^{5} + x \cdot \left(1 - \left(x \cdot x\right) \cdot 0.1666666666666666574148081281236954964697\right)\right) \cdot \frac{1}{1 + \cos x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \cos x} \cdot \frac{\left(1 + \cos x\right) \cdot \left(1 - \cos x\right)}{\sin x}\\
\end{array}double f(double x) {
double r3974690 = 1.0;
double r3974691 = x;
double r3974692 = cos(r3974691);
double r3974693 = r3974690 - r3974692;
double r3974694 = sin(r3974691);
double r3974695 = r3974693 / r3974694;
return r3974695;
}
double f(double x) {
double r3974696 = x;
double r3974697 = -0.027638311984739105;
bool r3974698 = r3974696 <= r3974697;
double r3974699 = 1.0;
double r3974700 = cos(r3974696);
double r3974701 = r3974699 - r3974700;
double r3974702 = sin(r3974696);
double r3974703 = r3974701 / r3974702;
double r3974704 = exp(r3974703);
double r3974705 = log(r3974704);
double r3974706 = 0.027845000675864373;
bool r3974707 = r3974696 <= r3974706;
double r3974708 = 0.008333333333333331;
double r3974709 = 5.0;
double r3974710 = pow(r3974696, r3974709);
double r3974711 = r3974708 * r3974710;
double r3974712 = r3974696 * r3974696;
double r3974713 = 0.16666666666666666;
double r3974714 = r3974712 * r3974713;
double r3974715 = r3974699 - r3974714;
double r3974716 = r3974696 * r3974715;
double r3974717 = r3974711 + r3974716;
double r3974718 = 1.0;
double r3974719 = r3974699 + r3974700;
double r3974720 = r3974718 / r3974719;
double r3974721 = r3974717 * r3974720;
double r3974722 = r3974719 * r3974701;
double r3974723 = r3974722 / r3974702;
double r3974724 = r3974720 * r3974723;
double r3974725 = r3974707 ? r3974721 : r3974724;
double r3974726 = r3974698 ? r3974705 : r3974725;
return r3974726;
}




Bits error versus x
Results
| Original | 30.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.027638311984739105Initial program 0.8
rmApplied add-log-exp1.0
if -0.027638311984739105 < x < 0.027845000675864373Initial program 59.9
rmApplied clear-num59.9
rmApplied flip--59.9
Applied associate-/r/59.9
Applied add-cube-cbrt59.9
Applied times-frac59.9
Simplified59.9
Simplified59.9
Taylor expanded around 0 0.0
Simplified0.0
if 0.027845000675864373 < x Initial program 0.9
rmApplied clear-num1.0
rmApplied flip--1.4
Applied associate-/r/1.4
Applied add-cube-cbrt1.4
Applied times-frac1.4
Simplified1.0
Simplified1.0
Final simplification0.5
herbie shell --seed 2019171
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))