\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.0107629324502667868:\\
\;\;\;\;\frac{\frac{{1}^{3}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1} - \frac{{\left(\cos x\right)}^{3}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 4.3298603204685633 \cdot 10^{-4}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{e^{\frac{1 - \cos x}{\sin x}}} \cdot \sqrt{e^{\frac{1 - \cos x}{\sin x}}}\right)\\
\end{array}double f(double x) {
double r43513 = 1.0;
double r43514 = x;
double r43515 = cos(r43514);
double r43516 = r43513 - r43515;
double r43517 = sin(r43514);
double r43518 = r43516 / r43517;
return r43518;
}
double f(double x) {
double r43519 = 1.0;
double r43520 = x;
double r43521 = cos(r43520);
double r43522 = r43519 - r43521;
double r43523 = sin(r43520);
double r43524 = r43522 / r43523;
double r43525 = -0.010762932450266787;
bool r43526 = r43524 <= r43525;
double r43527 = 3.0;
double r43528 = pow(r43519, r43527);
double r43529 = r43521 + r43519;
double r43530 = r43521 * r43529;
double r43531 = r43519 * r43519;
double r43532 = r43530 + r43531;
double r43533 = r43528 / r43532;
double r43534 = pow(r43521, r43527);
double r43535 = r43534 / r43532;
double r43536 = r43533 - r43535;
double r43537 = r43536 / r43523;
double r43538 = 0.00043298603204685633;
bool r43539 = r43524 <= r43538;
double r43540 = 0.041666666666666664;
double r43541 = pow(r43520, r43527);
double r43542 = r43540 * r43541;
double r43543 = 0.004166666666666667;
double r43544 = 5.0;
double r43545 = pow(r43520, r43544);
double r43546 = r43543 * r43545;
double r43547 = 0.5;
double r43548 = r43547 * r43520;
double r43549 = r43546 + r43548;
double r43550 = r43542 + r43549;
double r43551 = exp(r43524);
double r43552 = sqrt(r43551);
double r43553 = r43552 * r43552;
double r43554 = log(r43553);
double r43555 = r43539 ? r43550 : r43554;
double r43556 = r43526 ? r43537 : r43555;
return r43556;
}




Bits error versus x
Results
| Original | 30.1 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.010762932450266787Initial program 0.9
rmApplied flip3--1.0
Simplified1.0
rmApplied div-sub1.0
if -0.010762932450266787 < (/ (- 1.0 (cos x)) (sin x)) < 0.00043298603204685633Initial program 59.8
Taylor expanded around 0 0.3
if 0.00043298603204685633 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.0
rmApplied add-log-exp1.0
rmApplied add-sqr-sqrt1.3
Final simplification0.7
herbie shell --seed 2020056
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))