\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.004972647923616153355086400011941805132665:\\
\;\;\;\;\frac{\frac{1 \cdot \left(1 \cdot 1\right) - \cos x \cdot \left(\cos x \cdot \cos x\right)}{\mathsf{fma}\left(\cos x, \frac{\cos x \cdot \cos x - 1 \cdot 1}{\cos x - 1}, 1 \cdot 1\right)}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 1.24535172833726550875588223732393089449 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{240}, {x}^{5}, x \cdot \mathsf{fma}\left(x \cdot \frac{1}{24}, x, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 \cdot \left(1 \cdot 1\right) - \cos x \cdot \left(\cos x \cdot \cos x\right)}{\mathsf{fma}\left(\cos x, \frac{\cos x \cdot \cos x - 1 \cdot 1}{\cos x - 1}, 1 \cdot 1\right)}}{\sin x}\\
\end{array}double f(double x) {
double r2217025 = 1.0;
double r2217026 = x;
double r2217027 = cos(r2217026);
double r2217028 = r2217025 - r2217027;
double r2217029 = sin(r2217026);
double r2217030 = r2217028 / r2217029;
return r2217030;
}
double f(double x) {
double r2217031 = 1.0;
double r2217032 = x;
double r2217033 = cos(r2217032);
double r2217034 = r2217031 - r2217033;
double r2217035 = sin(r2217032);
double r2217036 = r2217034 / r2217035;
double r2217037 = -0.004972647923616153;
bool r2217038 = r2217036 <= r2217037;
double r2217039 = r2217031 * r2217031;
double r2217040 = r2217031 * r2217039;
double r2217041 = r2217033 * r2217033;
double r2217042 = r2217033 * r2217041;
double r2217043 = r2217040 - r2217042;
double r2217044 = r2217041 - r2217039;
double r2217045 = r2217033 - r2217031;
double r2217046 = r2217044 / r2217045;
double r2217047 = fma(r2217033, r2217046, r2217039);
double r2217048 = r2217043 / r2217047;
double r2217049 = r2217048 / r2217035;
double r2217050 = 1.2453517283372655e-05;
bool r2217051 = r2217036 <= r2217050;
double r2217052 = 0.004166666666666667;
double r2217053 = 5.0;
double r2217054 = pow(r2217032, r2217053);
double r2217055 = 0.041666666666666664;
double r2217056 = r2217032 * r2217055;
double r2217057 = 0.5;
double r2217058 = fma(r2217056, r2217032, r2217057);
double r2217059 = r2217032 * r2217058;
double r2217060 = fma(r2217052, r2217054, r2217059);
double r2217061 = r2217051 ? r2217060 : r2217049;
double r2217062 = r2217038 ? r2217049 : r2217061;
return r2217062;
}




Bits error versus x
| Original | 29.9 |
|---|---|
| Target | 0 |
| Herbie | 0.6 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.004972647923616153 or 1.2453517283372655e-05 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.0
rmApplied flip3--1.1
Simplified1.1
Simplified1.1
rmApplied flip-+1.1
if -0.004972647923616153 < (/ (- 1.0 (cos x)) (sin x)) < 1.2453517283372655e-05Initial program 60.0
Taylor expanded around 0 0.1
Simplified0.1
Final simplification0.6
herbie shell --seed 2019200 +o rules:numerics
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))