\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.022628612332283863:\\
\;\;\;\;\frac{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \sin x}\\
\mathbf{elif}\;x \le 0.02286088640089938:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{1}^{3} - \cos x \cdot {\left(\cos x\right)}^{2}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \sin x}\\
\end{array}double f(double x) {
double r83691 = 1.0;
double r83692 = x;
double r83693 = cos(r83692);
double r83694 = r83691 - r83693;
double r83695 = sin(r83692);
double r83696 = r83694 / r83695;
return r83696;
}
double f(double x) {
double r83697 = x;
double r83698 = -0.022628612332283863;
bool r83699 = r83697 <= r83698;
double r83700 = 1.0;
double r83701 = 3.0;
double r83702 = pow(r83700, r83701);
double r83703 = cos(r83697);
double r83704 = pow(r83703, r83701);
double r83705 = pow(r83704, r83701);
double r83706 = cbrt(r83705);
double r83707 = r83702 - r83706;
double r83708 = r83703 + r83700;
double r83709 = r83703 * r83708;
double r83710 = r83700 * r83700;
double r83711 = r83709 + r83710;
double r83712 = sin(r83697);
double r83713 = r83711 * r83712;
double r83714 = r83707 / r83713;
double r83715 = 0.02286088640089938;
bool r83716 = r83697 <= r83715;
double r83717 = 0.041666666666666664;
double r83718 = pow(r83697, r83701);
double r83719 = r83717 * r83718;
double r83720 = 0.004166666666666667;
double r83721 = 5.0;
double r83722 = pow(r83697, r83721);
double r83723 = r83720 * r83722;
double r83724 = 0.5;
double r83725 = r83724 * r83697;
double r83726 = r83723 + r83725;
double r83727 = r83719 + r83726;
double r83728 = 2.0;
double r83729 = pow(r83703, r83728);
double r83730 = r83703 * r83729;
double r83731 = r83702 - r83730;
double r83732 = r83731 / r83713;
double r83733 = r83716 ? r83727 : r83732;
double r83734 = r83699 ? r83714 : r83733;
return r83734;
}




Bits error versus x
Results
| Original | 30.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.022628612332283863Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-cbrt-cube1.1
Simplified1.1
if -0.022628612332283863 < x < 0.02286088640089938Initial program 59.9
Taylor expanded around 0 0.0
if 0.02286088640089938 < x Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied cube-mult1.0
Simplified1.0
Final simplification0.5
herbie shell --seed 2020065
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))