\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0192164982803571076 \lor \neg \left(x \le 0.0203937394598384565\right):\\
\;\;\;\;\frac{\frac{\sqrt{1}}{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 r51934 = 1.0;
double r51935 = x;
double r51936 = cos(r51935);
double r51937 = r51934 - r51936;
double r51938 = sin(r51935);
double r51939 = r51937 / r51938;
return r51939;
}
double f(double x) {
double r51940 = x;
double r51941 = -0.019216498280357108;
bool r51942 = r51940 <= r51941;
double r51943 = 0.020393739459838457;
bool r51944 = r51940 <= r51943;
double r51945 = !r51944;
bool r51946 = r51942 || r51945;
double r51947 = 1.0;
double r51948 = sqrt(r51947);
double r51949 = r51948 / r51947;
double r51950 = sin(r51940);
double r51951 = 1.0;
double r51952 = cos(r51940);
double r51953 = r51951 - r51952;
double r51954 = r51950 / r51953;
double r51955 = r51949 / r51954;
double r51956 = 0.041666666666666664;
double r51957 = 3.0;
double r51958 = pow(r51940, r51957);
double r51959 = r51956 * r51958;
double r51960 = 0.004166666666666667;
double r51961 = 5.0;
double r51962 = pow(r51940, r51961);
double r51963 = r51960 * r51962;
double r51964 = 0.5;
double r51965 = r51964 * r51940;
double r51966 = r51963 + r51965;
double r51967 = r51959 + r51966;
double r51968 = r51946 ? r51955 : r51967;
return r51968;
}




Bits error versus x
Results
| Original | 29.6 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.019216498280357108 or 0.020393739459838457 < x Initial program 0.9
rmApplied clear-num1.0
rmApplied div-inv1.0
Applied associate-/r*1.0
rmApplied *-un-lft-identity1.0
Applied add-sqr-sqrt1.0
Applied times-frac1.0
Applied associate-/l*1.1
Simplified1.0
if -0.019216498280357108 < x < 0.020393739459838457Initial program 59.9
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2020060
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))