\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.022146274038337438 \lor \neg \left(x \le 0.020167170543871162\right):\\
\;\;\;\;\frac{\frac{1 - \cos x}{\sin x} \cdot \left(\frac{1}{\sin x} \cdot \left(\cos x + 1\right)\right)}{\frac{1}{\sin x} \cdot \left(\cos x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666671 \cdot {x}^{3} + \left(0.00416666666666666661 \cdot {x}^{5} + 0.5 \cdot x\right)\\
\end{array}double f(double x) {
double r59510 = 1.0;
double r59511 = x;
double r59512 = cos(r59511);
double r59513 = r59510 - r59512;
double r59514 = sin(r59511);
double r59515 = r59513 / r59514;
return r59515;
}
double f(double x) {
double r59516 = x;
double r59517 = -0.022146274038337438;
bool r59518 = r59516 <= r59517;
double r59519 = 0.02016717054387116;
bool r59520 = r59516 <= r59519;
double r59521 = !r59520;
bool r59522 = r59518 || r59521;
double r59523 = 1.0;
double r59524 = cos(r59516);
double r59525 = r59523 - r59524;
double r59526 = sin(r59516);
double r59527 = r59525 / r59526;
double r59528 = 1.0;
double r59529 = r59528 / r59526;
double r59530 = r59524 + r59523;
double r59531 = r59529 * r59530;
double r59532 = r59527 * r59531;
double r59533 = r59532 / r59531;
double r59534 = 0.04166666666666667;
double r59535 = 3.0;
double r59536 = pow(r59516, r59535);
double r59537 = r59534 * r59536;
double r59538 = 0.004166666666666667;
double r59539 = 5.0;
double r59540 = pow(r59516, r59539);
double r59541 = r59538 * r59540;
double r59542 = 0.5;
double r59543 = r59542 * r59516;
double r59544 = r59541 + r59543;
double r59545 = r59537 + r59544;
double r59546 = r59522 ? r59533 : r59545;
return r59546;
}




Bits error versus x
Results
| Original | 30.1 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.022146274038337438 or 0.02016717054387116 < x Initial program 0.9
rmApplied div-sub1.1
rmApplied div-inv1.0
rmApplied flip--1.5
Simplified1.6
Simplified0.9
if -0.022146274038337438 < x < 0.02016717054387116Initial program 60.0
rmApplied div-sub60.0
rmApplied div-inv60.0
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2020033
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))