\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.0118953516307934663:\\
\;\;\;\;\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 2.2776287241343477 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\log \left(e^{{1}^{3} - {\left(\cos x\right)}^{3}}\right)}{\cos x \cdot \frac{{\left(\cos x\right)}^{2} - 1 \cdot 1}{\cos x - 1} + 1 \cdot 1}}{\sin x}\\
\end{array}double f(double x) {
double r54660 = 1.0;
double r54661 = x;
double r54662 = cos(r54661);
double r54663 = r54660 - r54662;
double r54664 = sin(r54661);
double r54665 = r54663 / r54664;
return r54665;
}
double f(double x) {
double r54666 = 1.0;
double r54667 = x;
double r54668 = cos(r54667);
double r54669 = r54666 - r54668;
double r54670 = sin(r54667);
double r54671 = r54669 / r54670;
double r54672 = -0.011895351630793466;
bool r54673 = r54671 <= r54672;
double r54674 = exp(r54671);
double r54675 = log(r54674);
double r54676 = 2.2776287241343477e-05;
bool r54677 = r54671 <= r54676;
double r54678 = 0.041666666666666664;
double r54679 = 3.0;
double r54680 = pow(r54667, r54679);
double r54681 = r54678 * r54680;
double r54682 = 0.004166666666666667;
double r54683 = 5.0;
double r54684 = pow(r54667, r54683);
double r54685 = r54682 * r54684;
double r54686 = 0.5;
double r54687 = r54686 * r54667;
double r54688 = r54685 + r54687;
double r54689 = r54681 + r54688;
double r54690 = pow(r54666, r54679);
double r54691 = pow(r54668, r54679);
double r54692 = r54690 - r54691;
double r54693 = exp(r54692);
double r54694 = log(r54693);
double r54695 = 2.0;
double r54696 = pow(r54668, r54695);
double r54697 = r54666 * r54666;
double r54698 = r54696 - r54697;
double r54699 = r54668 - r54666;
double r54700 = r54698 / r54699;
double r54701 = r54668 * r54700;
double r54702 = r54701 + r54697;
double r54703 = r54694 / r54702;
double r54704 = r54703 / r54670;
double r54705 = r54677 ? r54689 : r54704;
double r54706 = r54673 ? r54675 : r54705;
return r54706;
}




Bits error versus x
Results
| Original | 29.8 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.011895351630793466Initial program 0.8
rmApplied add-log-exp1.0
if -0.011895351630793466 < (/ (- 1.0 (cos x)) (sin x)) < 2.2776287241343477e-05Initial program 60.0
Taylor expanded around 0 0.2
if 2.2776287241343477e-05 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.1
rmApplied flip3--1.2
Simplified1.2
rmApplied add-log-exp1.2
Applied add-log-exp1.2
Applied diff-log1.3
Simplified1.2
rmApplied flip-+1.2
Simplified1.2
Final simplification0.7
herbie shell --seed 2020018
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))