\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.03628702050037945631144609137663792353123:\\
\;\;\;\;\frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{1 \cdot 1 + \left(1 + \cos x\right) \cdot \cos x}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 1.622109525504273900412314200758512328093 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\log \left(\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}\right)}}{\sin x}\\
\end{array}double f(double x) {
double r55420 = 1.0;
double r55421 = x;
double r55422 = cos(r55421);
double r55423 = r55420 - r55422;
double r55424 = sin(r55421);
double r55425 = r55423 / r55424;
return r55425;
}
double f(double x) {
double r55426 = 1.0;
double r55427 = x;
double r55428 = cos(r55427);
double r55429 = r55426 - r55428;
double r55430 = sin(r55427);
double r55431 = r55429 / r55430;
double r55432 = -0.036287020500379456;
bool r55433 = r55431 <= r55432;
double r55434 = 3.0;
double r55435 = pow(r55426, r55434);
double r55436 = pow(r55428, r55434);
double r55437 = r55435 - r55436;
double r55438 = r55426 * r55426;
double r55439 = r55426 + r55428;
double r55440 = r55439 * r55428;
double r55441 = r55438 + r55440;
double r55442 = r55437 / r55441;
double r55443 = r55442 / r55430;
double r55444 = 1.622109525504274e-06;
bool r55445 = r55431 <= r55444;
double r55446 = 0.041666666666666664;
double r55447 = pow(r55427, r55434);
double r55448 = r55446 * r55447;
double r55449 = 0.004166666666666667;
double r55450 = 5.0;
double r55451 = pow(r55427, r55450);
double r55452 = r55449 * r55451;
double r55453 = 0.5;
double r55454 = r55453 * r55427;
double r55455 = r55452 + r55454;
double r55456 = r55448 + r55455;
double r55457 = r55428 * r55428;
double r55458 = r55438 - r55457;
double r55459 = r55458 / r55439;
double r55460 = log(r55459);
double r55461 = exp(r55460);
double r55462 = r55461 / r55430;
double r55463 = r55445 ? r55456 : r55462;
double r55464 = r55433 ? r55443 : r55463;
return r55464;
}




Bits error versus x
Results
| Original | 30.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.9 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.036287020500379456Initial program 0.7
rmApplied add-exp-log0.7
rmApplied flip3--0.8
Applied log-div0.8
Applied exp-diff0.8
Simplified0.8
Simplified0.8
if -0.036287020500379456 < (/ (- 1.0 (cos x)) (sin x)) < 1.622109525504274e-06Initial program 59.5
Taylor expanded around 0 0.7
if 1.622109525504274e-06 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.1
rmApplied add-exp-log1.1
rmApplied flip--1.6
Final simplification0.9
herbie shell --seed 2019304
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))