\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02120801236249347798690223498851992189884 \lor \neg \left(x \le 0.02196010544527774235867845220582239562646\right):\\
\;\;\;\;\frac{\frac{\left(1 - \cos x\right) \cdot \left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right)}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}{\sin x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\end{array}double f(double x) {
double r68476 = 1.0;
double r68477 = x;
double r68478 = cos(r68477);
double r68479 = r68476 - r68478;
double r68480 = sin(r68477);
double r68481 = r68479 / r68480;
return r68481;
}
double f(double x) {
double r68482 = x;
double r68483 = -0.021208012362493478;
bool r68484 = r68482 <= r68483;
double r68485 = 0.021960105445277742;
bool r68486 = r68482 <= r68485;
double r68487 = !r68486;
bool r68488 = r68484 || r68487;
double r68489 = 1.0;
double r68490 = cos(r68482);
double r68491 = r68489 - r68490;
double r68492 = r68490 + r68489;
double r68493 = r68490 * r68492;
double r68494 = r68489 * r68489;
double r68495 = r68493 + r68494;
double r68496 = r68491 * r68495;
double r68497 = r68496 / r68495;
double r68498 = sin(r68482);
double r68499 = r68497 / r68498;
double r68500 = 0.041666666666666664;
double r68501 = 3.0;
double r68502 = pow(r68482, r68501);
double r68503 = r68500 * r68502;
double r68504 = 0.004166666666666667;
double r68505 = 5.0;
double r68506 = pow(r68482, r68505);
double r68507 = r68504 * r68506;
double r68508 = 0.5;
double r68509 = r68508 * r68482;
double r68510 = r68507 + r68509;
double r68511 = r68503 + r68510;
double r68512 = r68488 ? r68499 : r68511;
return r68512;
}




Bits error versus x
Results
| Original | 30.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.021208012362493478 or 0.021960105445277742 < x Initial program 0.9
rmApplied flip3--1.0
Simplified1.0
rmApplied add-log-exp1.1
Applied add-log-exp1.1
Applied diff-log1.1
Simplified1.0
rmApplied difference-cubes1.0
Applied exp-prod1.1
Applied log-pow1.1
Simplified0.9
if -0.021208012362493478 < x < 0.021960105445277742Initial program 59.9
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2019306
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))