\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0246265005946238076 \lor \neg \left(x \le 0.023818992858148251\right):\\
\;\;\;\;\frac{{1}^{3} - \sqrt[3]{{\left(\cos x\right)}^{9}}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \sin x}\\
\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 r49163 = 1.0;
double r49164 = x;
double r49165 = cos(r49164);
double r49166 = r49163 - r49165;
double r49167 = sin(r49164);
double r49168 = r49166 / r49167;
return r49168;
}
double f(double x) {
double r49169 = x;
double r49170 = -0.024626500594623808;
bool r49171 = r49169 <= r49170;
double r49172 = 0.02381899285814825;
bool r49173 = r49169 <= r49172;
double r49174 = !r49173;
bool r49175 = r49171 || r49174;
double r49176 = 1.0;
double r49177 = 3.0;
double r49178 = pow(r49176, r49177);
double r49179 = cos(r49169);
double r49180 = 9.0;
double r49181 = pow(r49179, r49180);
double r49182 = cbrt(r49181);
double r49183 = r49178 - r49182;
double r49184 = r49179 + r49176;
double r49185 = r49179 * r49184;
double r49186 = r49176 * r49176;
double r49187 = r49185 + r49186;
double r49188 = sin(r49169);
double r49189 = r49187 * r49188;
double r49190 = r49183 / r49189;
double r49191 = 0.041666666666666664;
double r49192 = pow(r49169, r49177);
double r49193 = r49191 * r49192;
double r49194 = 0.004166666666666667;
double r49195 = 5.0;
double r49196 = pow(r49169, r49195);
double r49197 = r49194 * r49196;
double r49198 = 0.5;
double r49199 = r49198 * r49169;
double r49200 = r49197 + r49199;
double r49201 = r49193 + r49200;
double r49202 = r49175 ? r49190 : r49201;
return r49202;
}




Bits error versus x
Results
| Original | 29.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.024626500594623808 or 0.02381899285814825 < x Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-cbrt-cube1.1
Simplified1.1
rmApplied pow-pow1.1
Simplified1.1
if -0.024626500594623808 < x < 0.02381899285814825Initial program 59.8
Taylor expanded around 0 0.0
Final simplification0.6
herbie shell --seed 2020025
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))