\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0186108748404142064 \lor \neg \left(x \le 0.022419207862011653\right):\\
\;\;\;\;\frac{1}{\frac{\sin x}{\log \left(e^{1 - \cos x}\right)}}\\
\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 r61192 = 1.0;
double r61193 = x;
double r61194 = cos(r61193);
double r61195 = r61192 - r61194;
double r61196 = sin(r61193);
double r61197 = r61195 / r61196;
return r61197;
}
double f(double x) {
double r61198 = x;
double r61199 = -0.018610874840414206;
bool r61200 = r61198 <= r61199;
double r61201 = 0.022419207862011653;
bool r61202 = r61198 <= r61201;
double r61203 = !r61202;
bool r61204 = r61200 || r61203;
double r61205 = 1.0;
double r61206 = sin(r61198);
double r61207 = 1.0;
double r61208 = cos(r61198);
double r61209 = r61207 - r61208;
double r61210 = exp(r61209);
double r61211 = log(r61210);
double r61212 = r61206 / r61211;
double r61213 = r61205 / r61212;
double r61214 = 0.041666666666666664;
double r61215 = 3.0;
double r61216 = pow(r61198, r61215);
double r61217 = r61214 * r61216;
double r61218 = 0.004166666666666667;
double r61219 = 5.0;
double r61220 = pow(r61198, r61219);
double r61221 = r61218 * r61220;
double r61222 = 0.5;
double r61223 = r61222 * r61198;
double r61224 = r61221 + r61223;
double r61225 = r61217 + r61224;
double r61226 = r61204 ? r61213 : r61225;
return r61226;
}




Bits error versus x
Results
| Original | 30.6 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.018610874840414206 or 0.022419207862011653 < x Initial program 0.9
rmApplied clear-num0.9
rmApplied add-log-exp1.2
Applied add-log-exp1.2
Applied diff-log1.3
Simplified1.1
if -0.018610874840414206 < x < 0.022419207862011653Initial program 60.0
Taylor expanded around 0 0.0
Final simplification0.6
herbie shell --seed 2020035
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))