\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.004956373674174259849611878792075003730133:\\
\;\;\;\;\frac{{e}^{\left(\log \left(1 - \cos x\right)\right)}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 0.001149553159340110540173607311942305386765:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \frac{1}{24}, \frac{1}{2}\right), {x}^{5} \cdot \frac{1}{240}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin x} - \frac{\cos x}{\sin x}\\
\end{array}double f(double x) {
double r4261987 = 1.0;
double r4261988 = x;
double r4261989 = cos(r4261988);
double r4261990 = r4261987 - r4261989;
double r4261991 = sin(r4261988);
double r4261992 = r4261990 / r4261991;
return r4261992;
}
double f(double x) {
double r4261993 = 1.0;
double r4261994 = x;
double r4261995 = cos(r4261994);
double r4261996 = r4261993 - r4261995;
double r4261997 = sin(r4261994);
double r4261998 = r4261996 / r4261997;
double r4261999 = -0.00495637367417426;
bool r4262000 = r4261998 <= r4261999;
double r4262001 = exp(1.0);
double r4262002 = log(r4261996);
double r4262003 = pow(r4262001, r4262002);
double r4262004 = r4262003 / r4261997;
double r4262005 = 0.0011495531593401105;
bool r4262006 = r4261998 <= r4262005;
double r4262007 = 0.041666666666666664;
double r4262008 = r4261994 * r4262007;
double r4262009 = 0.5;
double r4262010 = fma(r4261994, r4262008, r4262009);
double r4262011 = 5.0;
double r4262012 = pow(r4261994, r4262011);
double r4262013 = 0.004166666666666667;
double r4262014 = r4262012 * r4262013;
double r4262015 = fma(r4261994, r4262010, r4262014);
double r4262016 = r4261993 / r4261997;
double r4262017 = r4261995 / r4261997;
double r4262018 = r4262016 - r4262017;
double r4262019 = r4262006 ? r4262015 : r4262018;
double r4262020 = r4262000 ? r4262004 : r4262019;
return r4262020;
}




Bits error versus x
| Original | 30.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.00495637367417426Initial program 0.9
rmApplied add-exp-log0.9
rmApplied pow10.9
Applied log-pow0.9
Applied exp-prod0.9
Simplified0.9
if -0.00495637367417426 < (/ (- 1.0 (cos x)) (sin x)) < 0.0011495531593401105Initial program 59.9
Taylor expanded around 0 0.1
Simplified0.2
if 0.0011495531593401105 < (/ (- 1.0 (cos x)) (sin x)) Initial program 0.9
rmApplied div-sub1.2
Final simplification0.6
herbie shell --seed 2019169 +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)))