\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02366290210440796099033988753035373520106:\\
\;\;\;\;\frac{\frac{1 \cdot \left(1 \cdot 1\right) - \log \left(e^{\cos x \cdot \cos x}\right) \cdot \cos x}{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}}{\sin x}\\
\mathbf{elif}\;x \le 0.02175021537778742269919618479434575419873:\\
\;\;\;\;x \cdot \left(\frac{1}{2} + x \cdot \left(x \cdot \frac{1}{24}\right)\right) + {x}^{5} \cdot \frac{1}{240}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(1 \cdot \left(1 \cdot 1\right) - \frac{1}{2} \cdot \cos x\right) - \left(\frac{1}{2} \cdot \cos \left(x \cdot 2\right)\right) \cdot \cos x}{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}}{\sin x}\\
\end{array}double f(double x) {
double r3830615 = 1.0;
double r3830616 = x;
double r3830617 = cos(r3830616);
double r3830618 = r3830615 - r3830617;
double r3830619 = sin(r3830616);
double r3830620 = r3830618 / r3830619;
return r3830620;
}
double f(double x) {
double r3830621 = x;
double r3830622 = -0.02366290210440796;
bool r3830623 = r3830621 <= r3830622;
double r3830624 = 1.0;
double r3830625 = r3830624 * r3830624;
double r3830626 = r3830624 * r3830625;
double r3830627 = cos(r3830621);
double r3830628 = r3830627 * r3830627;
double r3830629 = exp(r3830628);
double r3830630 = log(r3830629);
double r3830631 = r3830630 * r3830627;
double r3830632 = r3830626 - r3830631;
double r3830633 = r3830624 * r3830627;
double r3830634 = r3830628 + r3830633;
double r3830635 = r3830625 + r3830634;
double r3830636 = r3830632 / r3830635;
double r3830637 = sin(r3830621);
double r3830638 = r3830636 / r3830637;
double r3830639 = 0.021750215377787423;
bool r3830640 = r3830621 <= r3830639;
double r3830641 = 0.5;
double r3830642 = 0.041666666666666664;
double r3830643 = r3830621 * r3830642;
double r3830644 = r3830621 * r3830643;
double r3830645 = r3830641 + r3830644;
double r3830646 = r3830621 * r3830645;
double r3830647 = 5.0;
double r3830648 = pow(r3830621, r3830647);
double r3830649 = 0.004166666666666667;
double r3830650 = r3830648 * r3830649;
double r3830651 = r3830646 + r3830650;
double r3830652 = r3830641 * r3830627;
double r3830653 = r3830626 - r3830652;
double r3830654 = 2.0;
double r3830655 = r3830621 * r3830654;
double r3830656 = cos(r3830655);
double r3830657 = r3830641 * r3830656;
double r3830658 = r3830657 * r3830627;
double r3830659 = r3830653 - r3830658;
double r3830660 = r3830659 / r3830635;
double r3830661 = r3830660 / r3830637;
double r3830662 = r3830640 ? r3830651 : r3830661;
double r3830663 = r3830623 ? r3830638 : r3830662;
return r3830663;
}




Bits error versus x
Results
| Original | 30.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.02366290210440796Initial program 0.9
rmApplied flip3--1.0
Simplified1.0
rmApplied add-log-exp1.0
if -0.02366290210440796 < x < 0.021750215377787423Initial program 59.9
Taylor expanded around 0 0.0
Simplified0.0
if 0.021750215377787423 < x Initial program 0.9
rmApplied flip3--1.0
Simplified1.0
rmApplied sqr-cos0.9
Applied distribute-lft-in0.9
Applied associate--r+0.9
Final simplification0.5
herbie shell --seed 2019174
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))