\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.0107629324502667868:\\
\;\;\;\;\frac{\frac{{1}^{3}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1} - \frac{{\left(\cos x\right)}^{3}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 4.3298603204685633 \cdot 10^{-4}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{e^{\frac{1 - \cos x}{\sin x}}} \cdot \sqrt{e^{\frac{1 - \cos x}{\sin x}}}\right)\\
\end{array}double f(double x) {
double r62677 = 1.0;
double r62678 = x;
double r62679 = cos(r62678);
double r62680 = r62677 - r62679;
double r62681 = sin(r62678);
double r62682 = r62680 / r62681;
return r62682;
}
double f(double x) {
double r62683 = 1.0;
double r62684 = x;
double r62685 = cos(r62684);
double r62686 = r62683 - r62685;
double r62687 = sin(r62684);
double r62688 = r62686 / r62687;
double r62689 = -0.010762932450266787;
bool r62690 = r62688 <= r62689;
double r62691 = 3.0;
double r62692 = pow(r62683, r62691);
double r62693 = r62685 + r62683;
double r62694 = r62685 * r62693;
double r62695 = r62683 * r62683;
double r62696 = r62694 + r62695;
double r62697 = r62692 / r62696;
double r62698 = pow(r62685, r62691);
double r62699 = r62698 / r62696;
double r62700 = r62697 - r62699;
double r62701 = r62700 / r62687;
double r62702 = 0.00043298603204685633;
bool r62703 = r62688 <= r62702;
double r62704 = 0.041666666666666664;
double r62705 = pow(r62684, r62691);
double r62706 = r62704 * r62705;
double r62707 = 0.004166666666666667;
double r62708 = 5.0;
double r62709 = pow(r62684, r62708);
double r62710 = r62707 * r62709;
double r62711 = 0.5;
double r62712 = r62711 * r62684;
double r62713 = r62710 + r62712;
double r62714 = r62706 + r62713;
double r62715 = exp(r62688);
double r62716 = sqrt(r62715);
double r62717 = r62716 * r62716;
double r62718 = log(r62717);
double r62719 = r62703 ? r62714 : r62718;
double r62720 = r62690 ? r62701 : r62719;
return r62720;
}




Bits error versus x
Results
| Original | 30.1 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.010762932450266787Initial program 0.9
rmApplied flip3--1.0
Simplified1.0
rmApplied div-sub1.0
if -0.010762932450266787 < (/ (- 1.0 (cos x)) (sin x)) < 0.00043298603204685633Initial program 59.8
Taylor expanded around 0 0.3
if 0.00043298603204685633 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.0
rmApplied add-log-exp1.0
rmApplied add-sqr-sqrt1.3
Final simplification0.7
herbie shell --seed 2020056
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))