\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, x \cdot \frac{1}{24}, \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 r2847373 = 1.0;
double r2847374 = x;
double r2847375 = cos(r2847374);
double r2847376 = r2847373 - r2847375;
double r2847377 = sin(r2847374);
double r2847378 = r2847376 / r2847377;
return r2847378;
}
double f(double x) {
double r2847379 = 1.0;
double r2847380 = x;
double r2847381 = cos(r2847380);
double r2847382 = r2847379 - r2847381;
double r2847383 = sin(r2847380);
double r2847384 = r2847382 / r2847383;
double r2847385 = -0.004972647923616153;
bool r2847386 = r2847384 <= r2847385;
double r2847387 = r2847379 * r2847379;
double r2847388 = r2847379 * r2847387;
double r2847389 = r2847381 * r2847381;
double r2847390 = r2847381 * r2847389;
double r2847391 = r2847388 - r2847390;
double r2847392 = r2847389 - r2847387;
double r2847393 = r2847381 - r2847379;
double r2847394 = r2847392 / r2847393;
double r2847395 = fma(r2847381, r2847394, r2847387);
double r2847396 = r2847391 / r2847395;
double r2847397 = r2847396 / r2847383;
double r2847398 = 1.2453517283372655e-05;
bool r2847399 = r2847384 <= r2847398;
double r2847400 = 0.004166666666666667;
double r2847401 = 5.0;
double r2847402 = pow(r2847380, r2847401);
double r2847403 = 0.041666666666666664;
double r2847404 = r2847380 * r2847403;
double r2847405 = 0.5;
double r2847406 = fma(r2847380, r2847404, r2847405);
double r2847407 = r2847380 * r2847406;
double r2847408 = fma(r2847400, r2847402, r2847407);
double r2847409 = r2847399 ? r2847408 : r2847397;
double r2847410 = r2847386 ? r2847397 : r2847409;
return r2847410;
}




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
rmApplied add-log-exp60.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)))