\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.02115882893523894289766751342085626674816 \lor \neg \left(\frac{1 - \cos x}{\sin x} \le 7.646982874077240654179165799120276858503 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{1}{\frac{\sin x}{1 - \cos x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\end{array}double f(double x) {
double r57997 = 1.0;
double r57998 = x;
double r57999 = cos(r57998);
double r58000 = r57997 - r57999;
double r58001 = sin(r57998);
double r58002 = r58000 / r58001;
return r58002;
}
double f(double x) {
double r58003 = 1.0;
double r58004 = x;
double r58005 = cos(r58004);
double r58006 = r58003 - r58005;
double r58007 = sin(r58004);
double r58008 = r58006 / r58007;
double r58009 = -0.021158828935238943;
bool r58010 = r58008 <= r58009;
double r58011 = 7.64698287407724e-08;
bool r58012 = r58008 <= r58011;
double r58013 = !r58012;
bool r58014 = r58010 || r58013;
double r58015 = 1.0;
double r58016 = r58007 / r58006;
double r58017 = r58015 / r58016;
double r58018 = 0.041666666666666664;
double r58019 = 3.0;
double r58020 = pow(r58004, r58019);
double r58021 = r58018 * r58020;
double r58022 = 0.004166666666666667;
double r58023 = 5.0;
double r58024 = pow(r58004, r58023);
double r58025 = r58022 * r58024;
double r58026 = 0.5;
double r58027 = r58026 * r58004;
double r58028 = r58025 + r58027;
double r58029 = r58021 + r58028;
double r58030 = r58014 ? r58017 : r58029;
return r58030;
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.8 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.021158828935238943 or 7.64698287407724e-08 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.0
rmApplied clear-num1.1
if -0.021158828935238943 < (/ (- 1.0 (cos x)) (sin x)) < 7.64698287407724e-08Initial program 59.8
Taylor expanded around 0 0.5
Final simplification0.8
herbie shell --seed 2019303
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))