\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0228429574445969362:\\
\;\;\;\;\frac{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \left(1 - \cos x\right)}{\left(\cos x \cdot \frac{{\left(\cos x\right)}^{3} + {1}^{3}}{1 \cdot \left(1 - \cos x\right) + {\left(\cos x\right)}^{2}} + 1 \cdot 1\right) \cdot \sin x}\\
\mathbf{elif}\;x \le 0.022901800433462009:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{2} \cdot \cos x}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \sin x}\\
\end{array}double f(double x) {
double r65631 = 1.0;
double r65632 = x;
double r65633 = cos(r65632);
double r65634 = r65631 - r65633;
double r65635 = sin(r65632);
double r65636 = r65634 / r65635;
return r65636;
}
double f(double x) {
double r65637 = x;
double r65638 = -0.022842957444596936;
bool r65639 = r65637 <= r65638;
double r65640 = cos(r65637);
double r65641 = 1.0;
double r65642 = r65640 + r65641;
double r65643 = r65640 * r65642;
double r65644 = r65641 * r65641;
double r65645 = r65643 + r65644;
double r65646 = r65641 - r65640;
double r65647 = r65645 * r65646;
double r65648 = 3.0;
double r65649 = pow(r65640, r65648);
double r65650 = pow(r65641, r65648);
double r65651 = r65649 + r65650;
double r65652 = r65641 * r65646;
double r65653 = 2.0;
double r65654 = pow(r65640, r65653);
double r65655 = r65652 + r65654;
double r65656 = r65651 / r65655;
double r65657 = r65640 * r65656;
double r65658 = r65657 + r65644;
double r65659 = sin(r65637);
double r65660 = r65658 * r65659;
double r65661 = r65647 / r65660;
double r65662 = 0.02290180043346201;
bool r65663 = r65637 <= r65662;
double r65664 = 0.041666666666666664;
double r65665 = pow(r65637, r65648);
double r65666 = r65664 * r65665;
double r65667 = 0.004166666666666667;
double r65668 = 5.0;
double r65669 = pow(r65637, r65668);
double r65670 = r65667 * r65669;
double r65671 = 0.5;
double r65672 = r65671 * r65637;
double r65673 = r65670 + r65672;
double r65674 = r65666 + r65673;
double r65675 = r65654 * r65640;
double r65676 = r65650 - r65675;
double r65677 = r65645 * r65659;
double r65678 = r65676 / r65677;
double r65679 = r65663 ? r65674 : r65678;
double r65680 = r65639 ? r65661 : r65679;
return r65680;
}




Bits error versus x
Results
| Original | 29.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.022842957444596936Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied difference-cubes1.0
Simplified1.0
rmApplied flip3-+1.0
Simplified1.0
if -0.022842957444596936 < x < 0.02290180043346201Initial program 59.8
Taylor expanded around 0 0.0
if 0.02290180043346201 < x Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-cube-cbrt1.8
Applied unpow-prod-down1.8
Simplified1.3
Simplified1.0
Final simplification0.5
herbie shell --seed 2020049
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))