\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02231606801598658498808624983666959451512:\\
\;\;\;\;\frac{e^{\log \left({1}^{3} - {\left(\cos x\right)}^{3}\right)}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \sin x}\\
\mathbf{elif}\;x \le 0.02219699502236853819181483515876607270911:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;{e}^{\left(\log \left(1 - \cos x\right)\right)} \cdot \frac{1}{\sin x}\\
\end{array}double f(double x) {
double r61809 = 1.0;
double r61810 = x;
double r61811 = cos(r61810);
double r61812 = r61809 - r61811;
double r61813 = sin(r61810);
double r61814 = r61812 / r61813;
return r61814;
}
double f(double x) {
double r61815 = x;
double r61816 = -0.022316068015986585;
bool r61817 = r61815 <= r61816;
double r61818 = 1.0;
double r61819 = 3.0;
double r61820 = pow(r61818, r61819);
double r61821 = cos(r61815);
double r61822 = pow(r61821, r61819);
double r61823 = r61820 - r61822;
double r61824 = log(r61823);
double r61825 = exp(r61824);
double r61826 = r61821 + r61818;
double r61827 = r61821 * r61826;
double r61828 = r61818 * r61818;
double r61829 = r61827 + r61828;
double r61830 = sin(r61815);
double r61831 = r61829 * r61830;
double r61832 = r61825 / r61831;
double r61833 = 0.022196995022368538;
bool r61834 = r61815 <= r61833;
double r61835 = 0.041666666666666664;
double r61836 = pow(r61815, r61819);
double r61837 = r61835 * r61836;
double r61838 = 0.004166666666666667;
double r61839 = 5.0;
double r61840 = pow(r61815, r61839);
double r61841 = r61838 * r61840;
double r61842 = 0.5;
double r61843 = r61842 * r61815;
double r61844 = r61841 + r61843;
double r61845 = r61837 + r61844;
double r61846 = exp(1.0);
double r61847 = r61818 - r61821;
double r61848 = log(r61847);
double r61849 = pow(r61846, r61848);
double r61850 = 1.0;
double r61851 = r61850 / r61830;
double r61852 = r61849 * r61851;
double r61853 = r61834 ? r61845 : r61852;
double r61854 = r61817 ? r61832 : r61853;
return r61854;
}




Bits error versus x
Results
| Original | 29.9 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.022316068015986585Initial program 0.9
rmApplied add-exp-log0.9
rmApplied flip3--1.0
Applied log-div1.1
Applied exp-diff1.0
Applied associate-/l/1.0
Simplified1.0
if -0.022316068015986585 < x < 0.022196995022368538Initial program 59.9
Taylor expanded around 0 0.0
if 0.022196995022368538 < x Initial program 0.9
rmApplied add-exp-log0.9
rmApplied pow10.9
Applied log-pow0.9
Applied exp-prod1.0
Simplified1.0
rmApplied div-inv1.0
Final simplification0.5
herbie shell --seed 2019325
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))