\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.04371460353231055445677455395525612402707:\\
\;\;\;\;\frac{e^{\log \left({1}^{3} - \mathsf{expm1}\left(\mathsf{log1p}\left(\cos x \cdot \left(\cos x \cdot \cos x\right)\right)\right)\right)}}{\sin x \cdot \mathsf{fma}\left(\cos x, \frac{1 \cdot 1 - \cos x \cdot \cos x}{1 - \cos x}, 1 \cdot 1\right)}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 6.2937074645496283672486959037684073337 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{240}, {x}^{5}, x \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot \left(x \cdot x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{e}^{\left(\log \left(1 - \cos x\right)\right)}}{\sin x}\\
\end{array}double f(double x) {
double r2555490 = 1.0;
double r2555491 = x;
double r2555492 = cos(r2555491);
double r2555493 = r2555490 - r2555492;
double r2555494 = sin(r2555491);
double r2555495 = r2555493 / r2555494;
return r2555495;
}
double f(double x) {
double r2555496 = 1.0;
double r2555497 = x;
double r2555498 = cos(r2555497);
double r2555499 = r2555496 - r2555498;
double r2555500 = sin(r2555497);
double r2555501 = r2555499 / r2555500;
double r2555502 = -0.043714603532310554;
bool r2555503 = r2555501 <= r2555502;
double r2555504 = 3.0;
double r2555505 = pow(r2555496, r2555504);
double r2555506 = r2555498 * r2555498;
double r2555507 = r2555498 * r2555506;
double r2555508 = log1p(r2555507);
double r2555509 = expm1(r2555508);
double r2555510 = r2555505 - r2555509;
double r2555511 = log(r2555510);
double r2555512 = exp(r2555511);
double r2555513 = r2555496 * r2555496;
double r2555514 = r2555513 - r2555506;
double r2555515 = r2555514 / r2555499;
double r2555516 = fma(r2555498, r2555515, r2555513);
double r2555517 = r2555500 * r2555516;
double r2555518 = r2555512 / r2555517;
double r2555519 = 6.293707464549628e-05;
bool r2555520 = r2555501 <= r2555519;
double r2555521 = 0.004166666666666667;
double r2555522 = 5.0;
double r2555523 = pow(r2555497, r2555522);
double r2555524 = 0.5;
double r2555525 = 0.041666666666666664;
double r2555526 = r2555497 * r2555497;
double r2555527 = r2555525 * r2555526;
double r2555528 = r2555524 + r2555527;
double r2555529 = r2555497 * r2555528;
double r2555530 = fma(r2555521, r2555523, r2555529);
double r2555531 = exp(1.0);
double r2555532 = log(r2555499);
double r2555533 = pow(r2555531, r2555532);
double r2555534 = r2555533 / r2555500;
double r2555535 = r2555520 ? r2555530 : r2555534;
double r2555536 = r2555503 ? r2555518 : r2555535;
return r2555536;
}




Bits error versus x
| Original | 30.1 |
|---|---|
| Target | 0.0 |
| Herbie | 1.0 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.043714603532310554Initial program 0.7
rmApplied add-exp-log0.7
rmApplied flip3--0.8
Applied log-div0.8
Applied exp-diff0.8
Applied associate-/l/0.8
Simplified0.8
rmApplied expm1-log1p-u0.8
Simplified0.8
rmApplied flip-+0.8
if -0.043714603532310554 < (/ (- 1.0 (cos x)) (sin x)) < 6.293707464549628e-05Initial program 59.2
rmApplied add-exp-log59.2
Taylor expanded around 0 0.9
Simplified0.9
if 6.293707464549628e-05 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.1
rmApplied add-exp-log1.1
rmApplied pow11.1
Applied log-pow1.1
Applied exp-prod1.2
Simplified1.2
Final simplification1.0
herbie shell --seed 2019179 +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)))