\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02187035372515749864774647903686854988337 \lor \neg \left(x \le 0.02243777298164771269450845636583835585043\right):\\
\;\;\;\;\left(\left(\left(1 + \cos x\right) \cdot \left(1 - \cos x\right)\right) \cdot \frac{1}{\sin x}\right) \cdot \frac{1}{1 + \cos x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(x \cdot \frac{1}{2} + {x}^{5} \cdot \frac{1}{240}\right)\\
\end{array}double f(double x) {
double r33365 = 1.0;
double r33366 = x;
double r33367 = cos(r33366);
double r33368 = r33365 - r33367;
double r33369 = sin(r33366);
double r33370 = r33368 / r33369;
return r33370;
}
double f(double x) {
double r33371 = x;
double r33372 = -0.0218703537251575;
bool r33373 = r33371 <= r33372;
double r33374 = 0.022437772981647713;
bool r33375 = r33371 <= r33374;
double r33376 = !r33375;
bool r33377 = r33373 || r33376;
double r33378 = 1.0;
double r33379 = cos(r33371);
double r33380 = r33378 + r33379;
double r33381 = r33378 - r33379;
double r33382 = r33380 * r33381;
double r33383 = 1.0;
double r33384 = sin(r33371);
double r33385 = r33383 / r33384;
double r33386 = r33382 * r33385;
double r33387 = r33383 / r33380;
double r33388 = r33386 * r33387;
double r33389 = 0.041666666666666664;
double r33390 = 3.0;
double r33391 = pow(r33371, r33390);
double r33392 = r33389 * r33391;
double r33393 = 0.5;
double r33394 = r33371 * r33393;
double r33395 = 5.0;
double r33396 = pow(r33371, r33395);
double r33397 = 0.004166666666666667;
double r33398 = r33396 * r33397;
double r33399 = r33394 + r33398;
double r33400 = r33392 + r33399;
double r33401 = r33377 ? r33388 : r33400;
return r33401;
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.0218703537251575 or 0.022437772981647713 < x Initial program 0.9
rmApplied clear-num1.0
rmApplied flip--1.4
Applied associate-/r/1.4
Applied add-cube-cbrt1.4
Applied times-frac1.4
Simplified1.0
Simplified1.0
rmApplied div-inv1.1
if -0.0218703537251575 < x < 0.022437772981647713Initial program 59.9
rmApplied clear-num59.9
Taylor expanded around 0 0.0
Simplified0.0
Final simplification0.5
herbie shell --seed 2019194
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))