\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.001608059772693871567958434631862019159598:\\
\;\;\;\;\frac{\frac{1 \cdot \left(1 \cdot 1\right) - \cos x \cdot \left(\cos x \cdot \cos x\right)}{\sin x}}{\left(\cos x \cdot \cos x + 1 \cdot \cos x\right) + 1 \cdot 1}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 7.540623703770628424457225097432555571686 \cdot 10^{-7}:\\
\;\;\;\;\left(x \cdot \left(\left(x \cdot x\right) \cdot \frac{1}{24}\right) + x \cdot \frac{1}{2}\right) + \frac{1}{240} \cdot {x}^{5}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)\\
\end{array}double f(double x) {
double r2910872 = 1.0;
double r2910873 = x;
double r2910874 = cos(r2910873);
double r2910875 = r2910872 - r2910874;
double r2910876 = sin(r2910873);
double r2910877 = r2910875 / r2910876;
return r2910877;
}
double f(double x) {
double r2910878 = 1.0;
double r2910879 = x;
double r2910880 = cos(r2910879);
double r2910881 = r2910878 - r2910880;
double r2910882 = sin(r2910879);
double r2910883 = r2910881 / r2910882;
double r2910884 = -0.0016080597726938716;
bool r2910885 = r2910883 <= r2910884;
double r2910886 = r2910878 * r2910878;
double r2910887 = r2910878 * r2910886;
double r2910888 = r2910880 * r2910880;
double r2910889 = r2910880 * r2910888;
double r2910890 = r2910887 - r2910889;
double r2910891 = r2910890 / r2910882;
double r2910892 = r2910878 * r2910880;
double r2910893 = r2910888 + r2910892;
double r2910894 = r2910893 + r2910886;
double r2910895 = r2910891 / r2910894;
double r2910896 = 7.540623703770628e-07;
bool r2910897 = r2910883 <= r2910896;
double r2910898 = r2910879 * r2910879;
double r2910899 = 0.041666666666666664;
double r2910900 = r2910898 * r2910899;
double r2910901 = r2910879 * r2910900;
double r2910902 = 0.5;
double r2910903 = r2910879 * r2910902;
double r2910904 = r2910901 + r2910903;
double r2910905 = 0.004166666666666667;
double r2910906 = 5.0;
double r2910907 = pow(r2910879, r2910906);
double r2910908 = r2910905 * r2910907;
double r2910909 = r2910904 + r2910908;
double r2910910 = exp(r2910883);
double r2910911 = log(r2910910);
double r2910912 = r2910897 ? r2910909 : r2910911;
double r2910913 = r2910885 ? r2910895 : r2910912;
return r2910913;
}




Bits error versus x
Results
| Original | 30.1 |
|---|---|
| Target | 0 |
| Herbie | 0.6 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.0016080597726938716Initial program 0.9
rmApplied clear-num1.0
rmApplied flip3--1.0
Applied associate-/r/1.1
Applied associate-/r*1.1
Simplified1.0
if -0.0016080597726938716 < (/ (- 1.0 (cos x)) (sin x)) < 7.540623703770628e-07Initial program 60.2
Taylor expanded around 0 0
Simplified0.0
rmApplied distribute-lft-in0.0
if 7.540623703770628e-07 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.2
rmApplied add-log-exp1.3
Final simplification0.6
herbie shell --seed 2019168
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))