\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0211819715308778529:\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\sin x \cdot \left(\cos x \cdot \frac{{1}^{3} + {\left(\cos x\right)}^{3}}{\cos x \cdot \left(\cos x - 1\right) + 1 \cdot 1} + 1 \cdot 1\right)}\\
\mathbf{elif}\;x \le 0.024888732994626496:\\
\;\;\;\;0.04166666666666663 \cdot {x}^{3} + \left(0.004166666666666624 \cdot {x}^{5} + 0.5 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\sin x \cdot \left(\cos x \cdot \frac{1 \cdot 1 - {\left(\cos x\right)}^{2}}{1 - \cos x} + 1 \cdot 1\right)}\\
\end{array}double f(double x) {
double r68592 = 1.0;
double r68593 = x;
double r68594 = cos(r68593);
double r68595 = r68592 - r68594;
double r68596 = sin(r68593);
double r68597 = r68595 / r68596;
return r68597;
}
double f(double x) {
double r68598 = x;
double r68599 = -0.021181971530877853;
bool r68600 = r68598 <= r68599;
double r68601 = 1.0;
double r68602 = 3.0;
double r68603 = pow(r68601, r68602);
double r68604 = cos(r68598);
double r68605 = pow(r68604, r68602);
double r68606 = r68603 - r68605;
double r68607 = sin(r68598);
double r68608 = r68603 + r68605;
double r68609 = r68604 - r68601;
double r68610 = r68604 * r68609;
double r68611 = r68601 * r68601;
double r68612 = r68610 + r68611;
double r68613 = r68608 / r68612;
double r68614 = r68604 * r68613;
double r68615 = r68614 + r68611;
double r68616 = r68607 * r68615;
double r68617 = r68606 / r68616;
double r68618 = 0.024888732994626496;
bool r68619 = r68598 <= r68618;
double r68620 = 0.04166666666666663;
double r68621 = pow(r68598, r68602);
double r68622 = r68620 * r68621;
double r68623 = 0.004166666666666624;
double r68624 = 5.0;
double r68625 = pow(r68598, r68624);
double r68626 = r68623 * r68625;
double r68627 = 0.5;
double r68628 = r68627 * r68598;
double r68629 = r68626 + r68628;
double r68630 = r68622 + r68629;
double r68631 = 2.0;
double r68632 = pow(r68604, r68631);
double r68633 = r68611 - r68632;
double r68634 = r68601 - r68604;
double r68635 = r68633 / r68634;
double r68636 = r68604 * r68635;
double r68637 = r68636 + r68611;
double r68638 = r68607 * r68637;
double r68639 = r68606 / r68638;
double r68640 = r68619 ? r68630 : r68639;
double r68641 = r68600 ? r68617 : r68640;
return r68641;
}




Bits error versus x
Results
| Original | 30.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.021181971530877853Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied flip3-+1.0
Simplified1.0
if -0.021181971530877853 < x < 0.024888732994626496Initial program 59.9
rmApplied flip3--59.9
Applied associate-/l/59.9
Simplified59.9
Taylor expanded around 0 0.0
if 0.024888732994626496 < x Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied flip-+1.0
Simplified1.0
Final simplification0.5
herbie shell --seed 2020042
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))