\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0199905813077168142 \lor \neg \left(x \le 0.021452837467613652\right):\\
\;\;\;\;\sqrt[3]{{\left(\sqrt[3]{{\left(\frac{1 - \cos x}{\sin x}\right)}^{3}}\right)}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\end{array}double f(double x) {
double r60288 = 1.0;
double r60289 = x;
double r60290 = cos(r60289);
double r60291 = r60288 - r60290;
double r60292 = sin(r60289);
double r60293 = r60291 / r60292;
return r60293;
}
double f(double x) {
double r60294 = x;
double r60295 = -0.019990581307716814;
bool r60296 = r60294 <= r60295;
double r60297 = 0.02145283746761365;
bool r60298 = r60294 <= r60297;
double r60299 = !r60298;
bool r60300 = r60296 || r60299;
double r60301 = 1.0;
double r60302 = cos(r60294);
double r60303 = r60301 - r60302;
double r60304 = sin(r60294);
double r60305 = r60303 / r60304;
double r60306 = 3.0;
double r60307 = pow(r60305, r60306);
double r60308 = cbrt(r60307);
double r60309 = pow(r60308, r60306);
double r60310 = cbrt(r60309);
double r60311 = 0.041666666666666664;
double r60312 = pow(r60294, r60306);
double r60313 = r60311 * r60312;
double r60314 = 0.004166666666666667;
double r60315 = 5.0;
double r60316 = pow(r60294, r60315);
double r60317 = r60314 * r60316;
double r60318 = 0.5;
double r60319 = r60318 * r60294;
double r60320 = r60317 + r60319;
double r60321 = r60313 + r60320;
double r60322 = r60300 ? r60310 : r60321;
return r60322;
}




Bits error versus x
Results
| Original | 30.1 |
|---|---|
| Target | 0 |
| Herbie | 0.6 |
if x < -0.019990581307716814 or 0.02145283746761365 < x Initial program 0.9
rmApplied add-cbrt-cube1.1
Applied add-cbrt-cube1.3
Applied cbrt-undiv1.1
Simplified1.2
rmApplied add-cbrt-cube1.3
Applied add-cbrt-cube1.4
Applied cbrt-undiv1.3
Simplified1.2
if -0.019990581307716814 < x < 0.02145283746761365Initial program 59.8
Taylor expanded around 0 0.0
Final simplification0.6
herbie shell --seed 2020036
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))