\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.00408598860077935295:\\
\;\;\;\;\log \left(e^{\frac{1}{\sin x} - \frac{\cos x}{\sin x}}\right)\\
\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{e^{\log \left({1}^{3} - {\left(\cos x\right)}^{3}\right)}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \sin x}\\
\end{array}double f(double x) {
double r66589 = 1.0;
double r66590 = x;
double r66591 = cos(r66590);
double r66592 = r66589 - r66591;
double r66593 = sin(r66590);
double r66594 = r66592 / r66593;
return r66594;
}
double f(double x) {
double r66595 = 1.0;
double r66596 = x;
double r66597 = cos(r66596);
double r66598 = r66595 - r66597;
double r66599 = sin(r66596);
double r66600 = r66598 / r66599;
double r66601 = -0.004085988600779353;
bool r66602 = r66600 <= r66601;
double r66603 = r66595 / r66599;
double r66604 = r66597 / r66599;
double r66605 = r66603 - r66604;
double r66606 = exp(r66605);
double r66607 = log(r66606);
double r66608 = -0.0;
bool r66609 = r66600 <= r66608;
double r66610 = 0.041666666666666664;
double r66611 = 3.0;
double r66612 = pow(r66596, r66611);
double r66613 = r66610 * r66612;
double r66614 = 0.004166666666666667;
double r66615 = 5.0;
double r66616 = pow(r66596, r66615);
double r66617 = r66614 * r66616;
double r66618 = 0.5;
double r66619 = r66618 * r66596;
double r66620 = r66617 + r66619;
double r66621 = r66613 + r66620;
double r66622 = pow(r66595, r66611);
double r66623 = pow(r66597, r66611);
double r66624 = r66622 - r66623;
double r66625 = log(r66624);
double r66626 = exp(r66625);
double r66627 = r66597 + r66595;
double r66628 = r66597 * r66627;
double r66629 = r66595 * r66595;
double r66630 = r66628 + r66629;
double r66631 = r66630 * r66599;
double r66632 = r66626 / r66631;
double r66633 = r66609 ? r66621 : r66632;
double r66634 = r66602 ? r66607 : r66633;
return r66634;
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0 |
| Herbie | 0.8 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.004085988600779353Initial program 0.9
rmApplied add-log-exp1.1
rmApplied div-sub1.2
if -0.004085988600779353 < (/ (- 1.0 (cos x)) (sin x)) < -0.0Initial program 60.1
Taylor expanded around 0 0.1
if -0.0 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.5
rmApplied flip3--1.6
Applied associate-/l/1.6
Simplified1.7
rmApplied add-exp-log1.7
Final simplification0.8
herbie shell --seed 2020027
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))