\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.01939010062697287678501467667047108989209:\\
\;\;\;\;\frac{1 \cdot 1 + \frac{{\left(\cos x\right)}^{2} \cdot \left({\left(\cos x\right)}^{2} - 1 \cdot 1\right)}{\cos x \cdot \left(\cos x - 1\right)}}{\frac{\sin x}{\frac{1 - \cos x}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}}\\
\mathbf{elif}\;x \le 0.02404792443261856427216827114534680731595:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\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 r54739 = 1.0;
double r54740 = x;
double r54741 = cos(r54740);
double r54742 = r54739 - r54741;
double r54743 = sin(r54740);
double r54744 = r54742 / r54743;
return r54744;
}
double f(double x) {
double r54745 = x;
double r54746 = -0.019390100626972877;
bool r54747 = r54745 <= r54746;
double r54748 = 1.0;
double r54749 = r54748 * r54748;
double r54750 = cos(r54745);
double r54751 = 2.0;
double r54752 = pow(r54750, r54751);
double r54753 = r54752 - r54749;
double r54754 = r54752 * r54753;
double r54755 = r54750 - r54748;
double r54756 = r54750 * r54755;
double r54757 = r54754 / r54756;
double r54758 = r54749 + r54757;
double r54759 = sin(r54745);
double r54760 = r54748 - r54750;
double r54761 = r54750 + r54748;
double r54762 = r54750 * r54761;
double r54763 = r54762 + r54749;
double r54764 = r54760 / r54763;
double r54765 = r54759 / r54764;
double r54766 = r54758 / r54765;
double r54767 = 0.024047924432618564;
bool r54768 = r54745 <= r54767;
double r54769 = 0.041666666666666664;
double r54770 = 3.0;
double r54771 = pow(r54745, r54770);
double r54772 = r54769 * r54771;
double r54773 = 0.004166666666666667;
double r54774 = 5.0;
double r54775 = pow(r54745, r54774);
double r54776 = r54773 * r54775;
double r54777 = 0.5;
double r54778 = r54777 * r54745;
double r54779 = r54776 + r54778;
double r54780 = r54772 + r54779;
double r54781 = pow(r54748, r54770);
double r54782 = pow(r54750, r54770);
double r54783 = r54781 - r54782;
double r54784 = r54753 / r54755;
double r54785 = r54750 * r54784;
double r54786 = r54785 + r54749;
double r54787 = r54783 / r54786;
double r54788 = r54787 / r54759;
double r54789 = r54768 ? r54780 : r54788;
double r54790 = r54747 ? r54766 : r54789;
return r54790;
}




Bits error versus x
Results
| Original | 30.9 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.019390100626972877Initial program 0.9
rmApplied flip3--1.1
Simplified1.1
rmApplied *-un-lft-identity1.1
Applied difference-cubes1.0
Applied times-frac1.1
Applied associate-/l*1.1
rmApplied flip-+1.1
Simplified1.1
Simplified1.1
if -0.019390100626972877 < x < 0.024047924432618564Initial program 59.9
Taylor expanded around 0 0.0
if 0.024047924432618564 < x Initial program 0.9
rmApplied flip3--1.0
Simplified1.0
rmApplied flip-+1.0
Simplified1.0
Final simplification0.5
herbie shell --seed 2019350
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))