\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02266404857182586010666547338132659206167:\\
\;\;\;\;\log \left(e^{\frac{1 \cdot \left(1 \cdot 1\right) - \cos x \cdot \left(\cos x \cdot \cos x\right)}{\left(\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1\right) \cdot \sin x}}\right)\\
\mathbf{elif}\;x \le 0.02109232526808033775234108020413259509951:\\
\;\;\;\;0.5 \cdot x + \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot 0.04166666666666662965923251249478198587894 + 0.004166666666666624108117389368999283760786 \cdot {x}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(1 \cdot \left(1 \cdot 1\right) - \cos x \cdot \frac{1}{2}\right) - \log \left(e^{\frac{1}{2} \cdot \cos \left(2 \cdot x\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 r4859568 = 1.0;
double r4859569 = x;
double r4859570 = cos(r4859569);
double r4859571 = r4859568 - r4859570;
double r4859572 = sin(r4859569);
double r4859573 = r4859571 / r4859572;
return r4859573;
}
double f(double x) {
double r4859574 = x;
double r4859575 = -0.02266404857182586;
bool r4859576 = r4859574 <= r4859575;
double r4859577 = 1.0;
double r4859578 = r4859577 * r4859577;
double r4859579 = r4859577 * r4859578;
double r4859580 = cos(r4859574);
double r4859581 = r4859580 * r4859580;
double r4859582 = r4859580 * r4859581;
double r4859583 = r4859579 - r4859582;
double r4859584 = r4859577 + r4859580;
double r4859585 = r4859580 * r4859584;
double r4859586 = r4859585 + r4859578;
double r4859587 = sin(r4859574);
double r4859588 = r4859586 * r4859587;
double r4859589 = r4859583 / r4859588;
double r4859590 = exp(r4859589);
double r4859591 = log(r4859590);
double r4859592 = 0.021092325268080338;
bool r4859593 = r4859574 <= r4859592;
double r4859594 = 0.5;
double r4859595 = r4859594 * r4859574;
double r4859596 = r4859574 * r4859574;
double r4859597 = r4859596 * r4859574;
double r4859598 = 0.04166666666666663;
double r4859599 = r4859597 * r4859598;
double r4859600 = 0.004166666666666624;
double r4859601 = 5.0;
double r4859602 = pow(r4859574, r4859601);
double r4859603 = r4859600 * r4859602;
double r4859604 = r4859599 + r4859603;
double r4859605 = r4859595 + r4859604;
double r4859606 = 0.5;
double r4859607 = r4859580 * r4859606;
double r4859608 = r4859579 - r4859607;
double r4859609 = 2.0;
double r4859610 = r4859609 * r4859574;
double r4859611 = cos(r4859610);
double r4859612 = r4859606 * r4859611;
double r4859613 = exp(r4859612);
double r4859614 = log(r4859613);
double r4859615 = r4859614 * r4859580;
double r4859616 = r4859608 - r4859615;
double r4859617 = r4859577 * r4859580;
double r4859618 = r4859581 + r4859617;
double r4859619 = r4859578 + r4859618;
double r4859620 = r4859616 / r4859619;
double r4859621 = r4859620 / r4859587;
double r4859622 = r4859593 ? r4859605 : r4859621;
double r4859623 = r4859576 ? r4859591 : r4859622;
return r4859623;
}




Bits error versus x
Results
| Original | 30.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.02266404857182586Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-log-exp1.3
Simplified1.2
if -0.02266404857182586 < x < 0.021092325268080338Initial program 59.9
rmApplied flip3--59.9
Applied associate-/l/59.9
Simplified59.9
Taylor expanded around 0 0.0
Simplified0.0
if 0.021092325268080338 < x Initial program 0.9
rmApplied flip3--1.0
Simplified1.0
rmApplied add-log-exp1.1
rmApplied sqr-cos1.0
Applied exp-sum1.0
Applied log-prod0.9
Applied distribute-rgt-in0.9
Applied associate--r+1.0
Simplified1.0
Final simplification0.6
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)))