\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02364773704659709624431584984449727926403:\\
\;\;\;\;\frac{\sqrt{e^{\log \left(1 - \cos x\right)}}}{\sin x} \cdot \sqrt{1 - \cos x}\\
\mathbf{elif}\;x \le 0.02077111946200701705911306760299339657649:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{{1}^{3} - {\left(\cos x\right)}^{3}}\right)}{\sin x \cdot \left(\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1\right)}\\
\end{array}double f(double x) {
double r64474 = 1.0;
double r64475 = x;
double r64476 = cos(r64475);
double r64477 = r64474 - r64476;
double r64478 = sin(r64475);
double r64479 = r64477 / r64478;
return r64479;
}
double f(double x) {
double r64480 = x;
double r64481 = -0.023647737046597096;
bool r64482 = r64480 <= r64481;
double r64483 = 1.0;
double r64484 = cos(r64480);
double r64485 = r64483 - r64484;
double r64486 = log(r64485);
double r64487 = exp(r64486);
double r64488 = sqrt(r64487);
double r64489 = sin(r64480);
double r64490 = r64488 / r64489;
double r64491 = sqrt(r64485);
double r64492 = r64490 * r64491;
double r64493 = 0.020771119462007017;
bool r64494 = r64480 <= r64493;
double r64495 = 0.041666666666666664;
double r64496 = 3.0;
double r64497 = pow(r64480, r64496);
double r64498 = r64495 * r64497;
double r64499 = 0.004166666666666667;
double r64500 = 5.0;
double r64501 = pow(r64480, r64500);
double r64502 = r64499 * r64501;
double r64503 = 0.5;
double r64504 = r64503 * r64480;
double r64505 = r64502 + r64504;
double r64506 = r64498 + r64505;
double r64507 = pow(r64483, r64496);
double r64508 = pow(r64484, r64496);
double r64509 = r64507 - r64508;
double r64510 = exp(r64509);
double r64511 = log(r64510);
double r64512 = r64483 + r64484;
double r64513 = r64484 * r64512;
double r64514 = r64483 * r64483;
double r64515 = r64513 + r64514;
double r64516 = r64489 * r64515;
double r64517 = r64511 / r64516;
double r64518 = r64494 ? r64506 : r64517;
double r64519 = r64482 ? r64492 : r64518;
return r64519;
}




Bits error versus x
Results
| Original | 30.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.023647737046597096Initial program 0.9
rmApplied add-log-exp1.0
rmApplied add-exp-log1.1
rmApplied *-un-lft-identity1.1
Applied add-sqr-sqrt1.2
Applied times-frac1.3
Applied exp-prod1.3
Applied log-pow1.2
Simplified1.1
if -0.023647737046597096 < x < 0.020771119462007017Initial program 60.0
Taylor expanded around 0 0.0
if 0.020771119462007017 < x Initial program 0.9
rmApplied flip3--1.1
Applied associate-/l/1.1
Simplified1.1
rmApplied add-log-exp1.1
Applied add-log-exp1.1
Applied diff-log1.2
Simplified1.1
Final simplification0.6
herbie shell --seed 2019326
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))