\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02231715051571105112859783048406825400889:\\
\;\;\;\;\frac{{1}^{3} - \frac{\sqrt[3]{\left(\cos x + \cos x \cdot \cos \left(x + x\right)\right) \cdot \left(\left(\cos x + \cos x \cdot \cos \left(x + x\right)\right) \cdot \left(\cos x + \cos x \cdot \cos \left(x + x\right)\right)\right)}}{\sqrt[3]{8}}}{\left(1 \cdot \left(1 + \cos x\right) + \cos x \cdot \cos x\right) \cdot \sin x}\\
\mathbf{elif}\;x \le 0.02105783752125852878456235828252829378471:\\
\;\;\;\;\left(0.5 + \left(x \cdot x\right) \cdot 0.04166666666666667129259593593815225176513\right) \cdot x + 0.004166666666666666608842550800773096852936 \cdot {x}^{5}\\
\mathbf{else}:\\
\;\;\;\;\frac{{1}^{3} - \sqrt[3]{\left(\left(\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right)\right) \cdot \left(\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right)\right)\right) \cdot \cos x}}{\left(\cos x \cdot \cos x + 1 \cdot \frac{1 \cdot 1 - \cos x \cdot \cos x}{1 - \cos x}\right) \cdot \sin x}\\
\end{array}double f(double x) {
double r2739830 = 1.0;
double r2739831 = x;
double r2739832 = cos(r2739831);
double r2739833 = r2739830 - r2739832;
double r2739834 = sin(r2739831);
double r2739835 = r2739833 / r2739834;
return r2739835;
}
double f(double x) {
double r2739836 = x;
double r2739837 = -0.02231715051571105;
bool r2739838 = r2739836 <= r2739837;
double r2739839 = 1.0;
double r2739840 = 3.0;
double r2739841 = pow(r2739839, r2739840);
double r2739842 = cos(r2739836);
double r2739843 = r2739836 + r2739836;
double r2739844 = cos(r2739843);
double r2739845 = r2739842 * r2739844;
double r2739846 = r2739842 + r2739845;
double r2739847 = r2739846 * r2739846;
double r2739848 = r2739846 * r2739847;
double r2739849 = cbrt(r2739848);
double r2739850 = 8.0;
double r2739851 = cbrt(r2739850);
double r2739852 = r2739849 / r2739851;
double r2739853 = r2739841 - r2739852;
double r2739854 = r2739839 + r2739842;
double r2739855 = r2739839 * r2739854;
double r2739856 = r2739842 * r2739842;
double r2739857 = r2739855 + r2739856;
double r2739858 = sin(r2739836);
double r2739859 = r2739857 * r2739858;
double r2739860 = r2739853 / r2739859;
double r2739861 = 0.02105783752125853;
bool r2739862 = r2739836 <= r2739861;
double r2739863 = 0.5;
double r2739864 = r2739836 * r2739836;
double r2739865 = 0.04166666666666667;
double r2739866 = r2739864 * r2739865;
double r2739867 = r2739863 + r2739866;
double r2739868 = r2739867 * r2739836;
double r2739869 = 0.004166666666666667;
double r2739870 = 5.0;
double r2739871 = pow(r2739836, r2739870);
double r2739872 = r2739869 * r2739871;
double r2739873 = r2739868 + r2739872;
double r2739874 = r2739856 * r2739856;
double r2739875 = r2739874 * r2739874;
double r2739876 = r2739875 * r2739842;
double r2739877 = cbrt(r2739876);
double r2739878 = r2739841 - r2739877;
double r2739879 = r2739839 * r2739839;
double r2739880 = r2739879 - r2739856;
double r2739881 = r2739839 - r2739842;
double r2739882 = r2739880 / r2739881;
double r2739883 = r2739839 * r2739882;
double r2739884 = r2739856 + r2739883;
double r2739885 = r2739884 * r2739858;
double r2739886 = r2739878 / r2739885;
double r2739887 = r2739862 ? r2739873 : r2739886;
double r2739888 = r2739838 ? r2739860 : r2739887;
return r2739888;
}




Bits error versus x
Results
| Original | 30.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.02231715051571105Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.1
rmApplied add-cbrt-cube1.1
Simplified1.1
rmApplied cos-mult1.2
Applied associate-*r/1.2
Applied cos-mult1.2
Applied cos-mult1.2
Applied frac-times1.2
Applied frac-times1.2
Applied associate-*l/1.2
Applied cbrt-div1.2
Simplified1.2
Simplified1.2
if -0.02231715051571105 < x < 0.02105783752125853Initial program 60.0
rmApplied div-sub60.0
Taylor expanded around 0 0.0
Simplified0.0
if 0.02105783752125853 < x Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-cbrt-cube1.1
Simplified1.1
rmApplied flip-+1.1
Final simplification0.6
herbie shell --seed 2019172
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))