\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le \frac{-385364116457663}{18014398509481984} \lor \neg \left(x \le \frac{5347175448897433}{288230376151711744}\right):\\
\;\;\;\;\frac{1}{\sin x} - \frac{\cos x}{\sin x}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{2} \cdot x + \frac{{x}^{5}}{240}\right) + \frac{{x}^{3}}{24}\\
\end{array}double f(double x) {
double r250659 = 1.0;
double r250660 = x;
double r250661 = cos(r250660);
double r250662 = r250659 - r250661;
double r250663 = sin(r250660);
double r250664 = r250662 / r250663;
return r250664;
}
double f(double x) {
double r250665 = x;
double r250666 = -385364116457663.0;
double r250667 = 18014398509481984.0;
double r250668 = r250666 / r250667;
bool r250669 = r250665 <= r250668;
double r250670 = 5347175448897433.0;
double r250671 = 2.8823037615171174e+17;
double r250672 = r250670 / r250671;
bool r250673 = r250665 <= r250672;
double r250674 = !r250673;
bool r250675 = r250669 || r250674;
double r250676 = 1.0;
double r250677 = sin(r250665);
double r250678 = r250676 / r250677;
double r250679 = cos(r250665);
double r250680 = r250679 / r250677;
double r250681 = r250678 - r250680;
double r250682 = 1.0;
double r250683 = 2.0;
double r250684 = r250682 / r250683;
double r250685 = r250684 * r250665;
double r250686 = 5.0;
double r250687 = pow(r250665, r250686);
double r250688 = 240.0;
double r250689 = r250687 / r250688;
double r250690 = r250685 + r250689;
double r250691 = 3.0;
double r250692 = pow(r250665, r250691);
double r250693 = 24.0;
double r250694 = r250692 / r250693;
double r250695 = r250690 + r250694;
double r250696 = r250675 ? r250681 : r250695;
return r250696;
}




Bits error versus x
Results
| Original | 30.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.021392005747781384Initial program 0.9
rmApplied add-exp-log1.0
rmApplied add-sqr-sqrt1.2
Applied associate-/l*1.2
Simplified1.2
if -0.021392005747781384 < x < 0.018551741562738398Initial program 59.8
Taylor expanded around 0 0.0
Simplified0.0
if 0.018551741562738398 < x Initial program 0.9
rmApplied add-exp-log0.9
rmApplied add-cbrt-cube1.1
Simplified1.1
Final simplification0.6
herbie shell --seed 350497007
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))