\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0227880187083014697224658817731324234046 \lor \neg \left(x \le 0.02338074252416355927608471176881721476093\right):\\
\;\;\;\;\frac{e^{\log \left(1 - \cos x\right)}}{\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 r56394 = 1.0;
double r56395 = x;
double r56396 = cos(r56395);
double r56397 = r56394 - r56396;
double r56398 = sin(r56395);
double r56399 = r56397 / r56398;
return r56399;
}
double f(double x) {
double r56400 = x;
double r56401 = -0.02278801870830147;
bool r56402 = r56400 <= r56401;
double r56403 = 0.02338074252416356;
bool r56404 = r56400 <= r56403;
double r56405 = !r56404;
bool r56406 = r56402 || r56405;
double r56407 = 1.0;
double r56408 = cos(r56400);
double r56409 = r56407 - r56408;
double r56410 = log(r56409);
double r56411 = exp(r56410);
double r56412 = sin(r56400);
double r56413 = r56411 / r56412;
double r56414 = 0.041666666666666664;
double r56415 = 3.0;
double r56416 = pow(r56400, r56415);
double r56417 = r56414 * r56416;
double r56418 = 0.004166666666666667;
double r56419 = 5.0;
double r56420 = pow(r56400, r56419);
double r56421 = r56418 * r56420;
double r56422 = 0.5;
double r56423 = r56422 * r56400;
double r56424 = r56421 + r56423;
double r56425 = r56417 + r56424;
double r56426 = r56406 ? r56413 : r56425;
return r56426;
}




Bits error versus x
Results
| Original | 30.4 |
|---|---|
| Target | 0 |
| Herbie | 0.5 |
if x < -0.02278801870830147 or 0.02338074252416356 < x Initial program 0.9
rmApplied add-log-exp1.1
Applied add-log-exp1.1
Applied diff-log1.3
Simplified1.1
rmApplied add-exp-log1.1
Simplified0.9
if -0.02278801870830147 < x < 0.02338074252416356Initial program 59.8
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2019351
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))