\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.008959247045566699763075035889414721168578:\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\left(\cos x \cdot \frac{\cos x \cdot \cos x - 1 \cdot 1}{\cos x - 1} + 1 \cdot 1\right) \cdot \sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 0.0:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\frac{1 - \cos x}{\sin x}\right)}\\
\end{array}double f(double x) {
double r57393 = 1.0;
double r57394 = x;
double r57395 = cos(r57394);
double r57396 = r57393 - r57395;
double r57397 = sin(r57394);
double r57398 = r57396 / r57397;
return r57398;
}
double f(double x) {
double r57399 = 1.0;
double r57400 = x;
double r57401 = cos(r57400);
double r57402 = r57399 - r57401;
double r57403 = sin(r57400);
double r57404 = r57402 / r57403;
double r57405 = -0.0089592470455667;
bool r57406 = r57404 <= r57405;
double r57407 = 3.0;
double r57408 = pow(r57399, r57407);
double r57409 = pow(r57401, r57407);
double r57410 = r57408 - r57409;
double r57411 = r57401 * r57401;
double r57412 = r57399 * r57399;
double r57413 = r57411 - r57412;
double r57414 = r57401 - r57399;
double r57415 = r57413 / r57414;
double r57416 = r57401 * r57415;
double r57417 = r57416 + r57412;
double r57418 = r57417 * r57403;
double r57419 = r57410 / r57418;
double r57420 = 0.0;
bool r57421 = r57404 <= r57420;
double r57422 = 0.041666666666666664;
double r57423 = pow(r57400, r57407);
double r57424 = r57422 * r57423;
double r57425 = 0.004166666666666667;
double r57426 = 5.0;
double r57427 = pow(r57400, r57426);
double r57428 = r57425 * r57427;
double r57429 = 0.5;
double r57430 = r57429 * r57400;
double r57431 = r57428 + r57430;
double r57432 = r57424 + r57431;
double r57433 = log(r57404);
double r57434 = exp(r57433);
double r57435 = r57421 ? r57432 : r57434;
double r57436 = r57406 ? r57419 : r57435;
return r57436;
}




Bits error versus x
Results
| Original | 30.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.0089592470455667Initial program 0.8
rmApplied flip3--0.9
Applied associate-/l/1.0
Simplified1.0
rmApplied add-sqr-sqrt1.0
rmApplied flip-+1.0
Applied sqrt-div64.0
Applied flip-+64.0
Applied sqrt-div64.0
Applied frac-times64.0
Simplified64.0
Simplified1.0
if -0.0089592470455667 < (/ (- 1.0 (cos x)) (sin x)) < 0.0Initial program 59.9
Taylor expanded around 0 0.3
if 0.0 < (/ (- 1.0 (cos x)) (sin x)) Initial program 29.8
rmApplied add-exp-log31.5
Applied add-exp-log31.5
Applied div-exp31.6
Simplified29.9
Final simplification0.7
herbie shell --seed 2019353
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))