\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -2.76308119989467809 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{{1}^{3} - \log \left(e^{{\left(\cos x\right)}^{3}}\right)}{\cos x \cdot \log \left(e^{\cos x + 1}\right) + 1 \cdot 1}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le -0.0:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin x} - \frac{\cos x}{\sin x}\\
\end{array}double f(double x) {
double r66951 = 1.0;
double r66952 = x;
double r66953 = cos(r66952);
double r66954 = r66951 - r66953;
double r66955 = sin(r66952);
double r66956 = r66954 / r66955;
return r66956;
}
double f(double x) {
double r66957 = 1.0;
double r66958 = x;
double r66959 = cos(r66958);
double r66960 = r66957 - r66959;
double r66961 = sin(r66958);
double r66962 = r66960 / r66961;
double r66963 = -0.0002763081199894678;
bool r66964 = r66962 <= r66963;
double r66965 = 3.0;
double r66966 = pow(r66957, r66965);
double r66967 = pow(r66959, r66965);
double r66968 = exp(r66967);
double r66969 = log(r66968);
double r66970 = r66966 - r66969;
double r66971 = r66959 + r66957;
double r66972 = exp(r66971);
double r66973 = log(r66972);
double r66974 = r66959 * r66973;
double r66975 = r66957 * r66957;
double r66976 = r66974 + r66975;
double r66977 = r66970 / r66976;
double r66978 = r66977 / r66961;
double r66979 = -0.0;
bool r66980 = r66962 <= r66979;
double r66981 = 0.041666666666666664;
double r66982 = pow(r66958, r66965);
double r66983 = r66981 * r66982;
double r66984 = 0.004166666666666667;
double r66985 = 5.0;
double r66986 = pow(r66958, r66985);
double r66987 = r66984 * r66986;
double r66988 = 0.5;
double r66989 = r66988 * r66958;
double r66990 = r66987 + r66989;
double r66991 = r66983 + r66990;
double r66992 = r66957 / r66961;
double r66993 = r66959 / r66961;
double r66994 = r66992 - r66993;
double r66995 = r66980 ? r66991 : r66994;
double r66996 = r66964 ? r66978 : r66995;
return r66996;
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.0002763081199894678Initial program 1.0
rmApplied flip3--1.1
Simplified1.2
rmApplied add-log-exp1.2
rmApplied add-log-exp1.2
Applied add-log-exp1.2
Applied sum-log1.2
Simplified1.2
if -0.0002763081199894678 < (/ (- 1.0 (cos x)) (sin x)) < -0.0Initial program 60.3
Taylor expanded around 0 0.0
if -0.0 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.3
rmApplied div-sub1.5
Final simplification0.7
herbie shell --seed 2020062
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))