\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le \frac{-6098617222933643}{288230376151711744} \lor \neg \left(\frac{1 - \cos x}{\sin x} \le \frac{722237112392411}{9444732965739290427392}\right):\\
\;\;\;\;\frac{1}{\frac{\sin x}{1 - \cos x}}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{2} \cdot x + \frac{1}{24} \cdot {x}^{3}\right) + \frac{{x}^{5}}{240}\\
\end{array}double f(double x) {
double r43100 = 1.0;
double r43101 = x;
double r43102 = cos(r43101);
double r43103 = r43100 - r43102;
double r43104 = sin(r43101);
double r43105 = r43103 / r43104;
return r43105;
}
double f(double x) {
double r43106 = 1.0;
double r43107 = x;
double r43108 = cos(r43107);
double r43109 = r43106 - r43108;
double r43110 = sin(r43107);
double r43111 = r43109 / r43110;
double r43112 = -6098617222933643.0;
double r43113 = 2.8823037615171174e+17;
double r43114 = r43112 / r43113;
bool r43115 = r43111 <= r43114;
double r43116 = 722237112392411.0;
double r43117 = 9.44473296573929e+21;
double r43118 = r43116 / r43117;
bool r43119 = r43111 <= r43118;
double r43120 = !r43119;
bool r43121 = r43115 || r43120;
double r43122 = 1.0;
double r43123 = r43110 / r43109;
double r43124 = r43122 / r43123;
double r43125 = 2.0;
double r43126 = r43122 / r43125;
double r43127 = r43126 * r43107;
double r43128 = 24.0;
double r43129 = r43122 / r43128;
double r43130 = 3.0;
double r43131 = pow(r43107, r43130);
double r43132 = r43129 * r43131;
double r43133 = r43127 + r43132;
double r43134 = 5.0;
double r43135 = pow(r43107, r43134);
double r43136 = 240.0;
double r43137 = r43135 / r43136;
double r43138 = r43133 + r43137;
double r43139 = r43121 ? r43124 : r43138;
return r43139;
}




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
rmApplied add-log-exp59.8
Applied add-log-exp59.8
Applied diff-log59.8
Simplified59.8
Taylor expanded around 0 0.5
Simplified0.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)))