\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.04371460353231055445677455395525612402707:\\
\;\;\;\;\frac{e^{\log \left({1}^{3} - {\left(\cos x\right)}^{3}\right)}}{\sin x \cdot \left(\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1\right)}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 6.2937074645496283672486959037684073337 \cdot 10^{-5}:\\
\;\;\;\;{x}^{5} \cdot \frac{1}{240} + \left(\frac{1}{2} + x \cdot \left(\frac{1}{24} \cdot x\right)\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{{e}^{\left(\log \left(1 - \cos x\right)\right)}}{\sin x}\\
\end{array}double f(double x) {
double r59844 = 1.0;
double r59845 = x;
double r59846 = cos(r59845);
double r59847 = r59844 - r59846;
double r59848 = sin(r59845);
double r59849 = r59847 / r59848;
return r59849;
}
double f(double x) {
double r59850 = 1.0;
double r59851 = x;
double r59852 = cos(r59851);
double r59853 = r59850 - r59852;
double r59854 = sin(r59851);
double r59855 = r59853 / r59854;
double r59856 = -0.043714603532310554;
bool r59857 = r59855 <= r59856;
double r59858 = 3.0;
double r59859 = pow(r59850, r59858);
double r59860 = pow(r59852, r59858);
double r59861 = r59859 - r59860;
double r59862 = log(r59861);
double r59863 = exp(r59862);
double r59864 = r59850 + r59852;
double r59865 = r59852 * r59864;
double r59866 = r59850 * r59850;
double r59867 = r59865 + r59866;
double r59868 = r59854 * r59867;
double r59869 = r59863 / r59868;
double r59870 = 6.293707464549628e-05;
bool r59871 = r59855 <= r59870;
double r59872 = 5.0;
double r59873 = pow(r59851, r59872);
double r59874 = 0.004166666666666667;
double r59875 = r59873 * r59874;
double r59876 = 0.5;
double r59877 = 0.041666666666666664;
double r59878 = r59877 * r59851;
double r59879 = r59851 * r59878;
double r59880 = r59876 + r59879;
double r59881 = r59880 * r59851;
double r59882 = r59875 + r59881;
double r59883 = exp(1.0);
double r59884 = log(r59853);
double r59885 = pow(r59883, r59884);
double r59886 = r59885 / r59854;
double r59887 = r59871 ? r59882 : r59886;
double r59888 = r59857 ? r59869 : r59887;
return r59888;
}




Bits error versus x
Results
| Original | 30.1 |
|---|---|
| Target | 0.0 |
| Herbie | 1.0 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.043714603532310554Initial program 0.7
rmApplied add-exp-log0.7
rmApplied flip3--0.8
Applied log-div0.8
Applied exp-diff0.8
Applied associate-/l/0.8
Simplified0.8
if -0.043714603532310554 < (/ (- 1.0 (cos x)) (sin x)) < 6.293707464549628e-05Initial program 59.2
Taylor expanded around 0 0.9
Simplified0.9
if 6.293707464549628e-05 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.1
rmApplied add-exp-log1.1
rmApplied pow11.1
Applied log-pow1.1
Applied exp-prod1.2
Simplified1.2
rmApplied pow11.2
Final simplification1.0
herbie shell --seed 2019179
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))