\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0198749278940998884 \lor \neg \left(x \le 0.022259987926796919\right):\\
\;\;\;\;\frac{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}{\frac{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \sin x}{1 - \cos x}}\\
\mathbf{else}:\\
\;\;\;\;0.04166666666666663 \cdot {x}^{3} + \left(0.004166666666666624 \cdot {x}^{5} + 0.5 \cdot x\right)\\
\end{array}double f(double x) {
double r53088 = 1.0;
double r53089 = x;
double r53090 = cos(r53089);
double r53091 = r53088 - r53090;
double r53092 = sin(r53089);
double r53093 = r53091 / r53092;
return r53093;
}
double f(double x) {
double r53094 = x;
double r53095 = -0.01987492789409989;
bool r53096 = r53094 <= r53095;
double r53097 = 0.02225998792679692;
bool r53098 = r53094 <= r53097;
double r53099 = !r53098;
bool r53100 = r53096 || r53099;
double r53101 = 1.0;
double r53102 = r53101 * r53101;
double r53103 = cos(r53094);
double r53104 = r53103 * r53103;
double r53105 = r53101 * r53103;
double r53106 = r53104 + r53105;
double r53107 = r53102 + r53106;
double r53108 = r53103 + r53101;
double r53109 = r53103 * r53108;
double r53110 = r53109 + r53102;
double r53111 = sin(r53094);
double r53112 = r53110 * r53111;
double r53113 = r53101 - r53103;
double r53114 = r53112 / r53113;
double r53115 = r53107 / r53114;
double r53116 = 0.04166666666666663;
double r53117 = 3.0;
double r53118 = pow(r53094, r53117);
double r53119 = r53116 * r53118;
double r53120 = 0.004166666666666624;
double r53121 = 5.0;
double r53122 = pow(r53094, r53121);
double r53123 = r53120 * r53122;
double r53124 = 0.5;
double r53125 = r53124 * r53094;
double r53126 = r53123 + r53125;
double r53127 = r53119 + r53126;
double r53128 = r53100 ? r53115 : r53127;
return r53128;
}




Bits error versus x
Results
| Original | 30.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.01987492789409989 or 0.02225998792679692 < x Initial program 0.8
rmApplied flip3--0.9
Applied associate-/l/1.0
Simplified1.0
rmApplied difference-cubes1.0
Applied associate-/l*1.0
if -0.01987492789409989 < x < 0.02225998792679692Initial program 59.8
rmApplied flip3--59.9
Applied associate-/l/59.9
Simplified59.9
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2020083
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))