\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -2.76308119989467809 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{{1}^{3} - \log \left(e^{{\left(\cos x\right)}^{3}}\right)}{\cos x \cdot \log \left(e^{\cos x + 1}\right) + 1 \cdot 1}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le -0.0:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin x} - \frac{\cos x}{\sin x}\\
\end{array}double f(double x) {
double r65511 = 1.0;
double r65512 = x;
double r65513 = cos(r65512);
double r65514 = r65511 - r65513;
double r65515 = sin(r65512);
double r65516 = r65514 / r65515;
return r65516;
}
double f(double x) {
double r65517 = 1.0;
double r65518 = x;
double r65519 = cos(r65518);
double r65520 = r65517 - r65519;
double r65521 = sin(r65518);
double r65522 = r65520 / r65521;
double r65523 = -0.0002763081199894678;
bool r65524 = r65522 <= r65523;
double r65525 = 3.0;
double r65526 = pow(r65517, r65525);
double r65527 = pow(r65519, r65525);
double r65528 = exp(r65527);
double r65529 = log(r65528);
double r65530 = r65526 - r65529;
double r65531 = r65519 + r65517;
double r65532 = exp(r65531);
double r65533 = log(r65532);
double r65534 = r65519 * r65533;
double r65535 = r65517 * r65517;
double r65536 = r65534 + r65535;
double r65537 = r65530 / r65536;
double r65538 = r65537 / r65521;
double r65539 = -0.0;
bool r65540 = r65522 <= r65539;
double r65541 = 0.041666666666666664;
double r65542 = pow(r65518, r65525);
double r65543 = r65541 * r65542;
double r65544 = 0.004166666666666667;
double r65545 = 5.0;
double r65546 = pow(r65518, r65545);
double r65547 = r65544 * r65546;
double r65548 = 0.5;
double r65549 = r65548 * r65518;
double r65550 = r65547 + r65549;
double r65551 = r65543 + r65550;
double r65552 = r65517 / r65521;
double r65553 = r65519 / r65521;
double r65554 = r65552 - r65553;
double r65555 = r65540 ? r65551 : r65554;
double r65556 = r65524 ? r65538 : r65555;
return r65556;
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.0002763081199894678Initial program 1.0
rmApplied flip3--1.1
Simplified1.2
rmApplied add-log-exp1.2
rmApplied add-log-exp1.2
Applied add-log-exp1.2
Applied sum-log1.2
Simplified1.2
if -0.0002763081199894678 < (/ (- 1.0 (cos x)) (sin x)) < -0.0Initial program 60.3
Taylor expanded around 0 0.0
if -0.0 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.3
rmApplied div-sub1.5
Final simplification0.7
herbie shell --seed 2020062
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))