\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.01849382956573876121697530550136434612796 \lor \neg \left(x \le 0.02173189858796714321598209096464415779337\right):\\
\;\;\;\;\frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\frac{\cos x \cdot \left(\cos x \cdot \cos x - 1 \cdot 1\right)}{\cos x - 1} + 1 \cdot 1}}{\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 r113388 = 1.0;
double r113389 = x;
double r113390 = cos(r113389);
double r113391 = r113388 - r113390;
double r113392 = sin(r113389);
double r113393 = r113391 / r113392;
return r113393;
}
double f(double x) {
double r113394 = x;
double r113395 = -0.01849382956573876;
bool r113396 = r113394 <= r113395;
double r113397 = 0.021731898587967143;
bool r113398 = r113394 <= r113397;
double r113399 = !r113398;
bool r113400 = r113396 || r113399;
double r113401 = 1.0;
double r113402 = 3.0;
double r113403 = pow(r113401, r113402);
double r113404 = cos(r113394);
double r113405 = pow(r113404, r113402);
double r113406 = r113403 - r113405;
double r113407 = r113404 * r113404;
double r113408 = r113401 * r113401;
double r113409 = r113407 - r113408;
double r113410 = r113404 * r113409;
double r113411 = r113404 - r113401;
double r113412 = r113410 / r113411;
double r113413 = r113412 + r113408;
double r113414 = r113406 / r113413;
double r113415 = sin(r113394);
double r113416 = r113414 / r113415;
double r113417 = 0.041666666666666664;
double r113418 = pow(r113394, r113402);
double r113419 = r113417 * r113418;
double r113420 = 0.004166666666666667;
double r113421 = 5.0;
double r113422 = pow(r113394, r113421);
double r113423 = r113420 * r113422;
double r113424 = 0.5;
double r113425 = r113424 * r113394;
double r113426 = r113423 + r113425;
double r113427 = r113419 + r113426;
double r113428 = r113400 ? r113416 : r113427;
return r113428;
}




Bits error versus x
Results
| Original | 30.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.01849382956573876 or 0.021731898587967143 < x Initial program 0.9
rmApplied flip3--1.0
Simplified1.0
rmApplied flip-+1.0
Applied associate-*r/1.0
if -0.01849382956573876 < x < 0.021731898587967143Initial program 59.8
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2019354
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))