\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0199905813077168142:\\
\;\;\;\;\sqrt[3]{{\left(\sqrt[3]{{\left(\frac{1 - \cos x}{\sin x}\right)}^{3}}\right)}^{3}}\\
\mathbf{elif}\;x \le 0.021452837467613652:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{1 - \cos x}}{\sin x} \cdot \sqrt{1 - \cos x}\\
\end{array}double f(double x) {
double r72038 = 1.0;
double r72039 = x;
double r72040 = cos(r72039);
double r72041 = r72038 - r72040;
double r72042 = sin(r72039);
double r72043 = r72041 / r72042;
return r72043;
}
double f(double x) {
double r72044 = x;
double r72045 = -0.019990581307716814;
bool r72046 = r72044 <= r72045;
double r72047 = 1.0;
double r72048 = cos(r72044);
double r72049 = r72047 - r72048;
double r72050 = sin(r72044);
double r72051 = r72049 / r72050;
double r72052 = 3.0;
double r72053 = pow(r72051, r72052);
double r72054 = cbrt(r72053);
double r72055 = pow(r72054, r72052);
double r72056 = cbrt(r72055);
double r72057 = 0.02145283746761365;
bool r72058 = r72044 <= r72057;
double r72059 = 0.041666666666666664;
double r72060 = pow(r72044, r72052);
double r72061 = r72059 * r72060;
double r72062 = 0.004166666666666667;
double r72063 = 5.0;
double r72064 = pow(r72044, r72063);
double r72065 = r72062 * r72064;
double r72066 = 0.5;
double r72067 = r72066 * r72044;
double r72068 = r72065 + r72067;
double r72069 = r72061 + r72068;
double r72070 = sqrt(r72049);
double r72071 = r72070 / r72050;
double r72072 = r72071 * r72070;
double r72073 = r72058 ? r72069 : r72072;
double r72074 = r72046 ? r72056 : r72073;
return r72074;
}




Bits error versus x
Results
| Original | 30.1 |
|---|---|
| Target | 0 |
| Herbie | 0.6 |
if x < -0.019990581307716814Initial program 0.9
rmApplied add-cbrt-cube1.1
Applied add-cbrt-cube1.3
Applied cbrt-undiv1.1
Simplified1.1
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
if 0.02145283746761365 < x Initial program 0.9
rmApplied add-log-exp1.0
rmApplied *-un-lft-identity1.0
Applied add-sqr-sqrt1.2
Applied times-frac1.2
Applied exp-prod1.2
Applied log-pow1.1
Simplified1.1
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)))