\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.0161525551537130101:\\
\;\;\;\;\frac{\frac{\log \left(e^{{1}^{3} - {\left(\cos x\right)}^{3}}\right)}{\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 8.0836609335251401 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\cos x \cdot \frac{1 \cdot 1 - {\left(\cos x\right)}^{2}}{1 - \cos x} + 1 \cdot 1}}{\sin x}\\
\end{array}double f(double x) {
double r45354 = 1.0;
double r45355 = x;
double r45356 = cos(r45355);
double r45357 = r45354 - r45356;
double r45358 = sin(r45355);
double r45359 = r45357 / r45358;
return r45359;
}
double f(double x) {
double r45360 = 1.0;
double r45361 = x;
double r45362 = cos(r45361);
double r45363 = r45360 - r45362;
double r45364 = sin(r45361);
double r45365 = r45363 / r45364;
double r45366 = -0.01615255515371301;
bool r45367 = r45365 <= r45366;
double r45368 = 3.0;
double r45369 = pow(r45360, r45368);
double r45370 = pow(r45362, r45368);
double r45371 = r45369 - r45370;
double r45372 = exp(r45371);
double r45373 = log(r45372);
double r45374 = r45360 + r45362;
double r45375 = r45362 * r45374;
double r45376 = r45360 * r45360;
double r45377 = r45375 + r45376;
double r45378 = r45373 / r45377;
double r45379 = r45378 / r45364;
double r45380 = 8.08366093352514e-05;
bool r45381 = r45365 <= r45380;
double r45382 = 0.041666666666666664;
double r45383 = pow(r45361, r45368);
double r45384 = r45382 * r45383;
double r45385 = 0.004166666666666667;
double r45386 = 5.0;
double r45387 = pow(r45361, r45386);
double r45388 = r45385 * r45387;
double r45389 = 0.5;
double r45390 = r45389 * r45361;
double r45391 = r45388 + r45390;
double r45392 = r45384 + r45391;
double r45393 = 2.0;
double r45394 = pow(r45362, r45393);
double r45395 = r45376 - r45394;
double r45396 = r45395 / r45363;
double r45397 = r45362 * r45396;
double r45398 = r45397 + r45376;
double r45399 = r45371 / r45398;
double r45400 = r45399 / r45364;
double r45401 = r45381 ? r45392 : r45400;
double r45402 = r45367 ? r45379 : r45401;
return r45402;
}




Bits error versus x
Results
| Original | 29.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.01615255515371301Initial program 0.8
rmApplied flip3--0.9
Simplified0.9
rmApplied add-log-exp1.0
Applied add-log-exp1.0
Applied diff-log1.0
Simplified0.9
if -0.01615255515371301 < (/ (- 1.0 (cos x)) (sin x)) < 8.08366093352514e-05Initial program 59.7
Taylor expanded around 0 0.4
if 8.08366093352514e-05 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.0
rmApplied flip3--1.1
Simplified1.1
rmApplied flip-+1.1
Simplified1.1
Final simplification0.7
herbie shell --seed 2020043
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))