\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.01962732699026020072308185149267956148833:\\
\;\;\;\;\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)\\
\mathbf{elif}\;x \le 0.02449600219494943789677598999787733191624:\\
\;\;\;\;\left({x}^{5} \cdot \frac{1}{240} + \frac{1}{2} \cdot x\right) + \left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{24}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \cos x} \cdot \frac{\left(1 + \cos x\right) \cdot \left(1 - \cos x\right)}{\sin x}\\
\end{array}double f(double x) {
double r2504279 = 1.0;
double r2504280 = x;
double r2504281 = cos(r2504280);
double r2504282 = r2504279 - r2504281;
double r2504283 = sin(r2504280);
double r2504284 = r2504282 / r2504283;
return r2504284;
}
double f(double x) {
double r2504285 = x;
double r2504286 = -0.0196273269902602;
bool r2504287 = r2504285 <= r2504286;
double r2504288 = 1.0;
double r2504289 = cos(r2504285);
double r2504290 = r2504288 - r2504289;
double r2504291 = sin(r2504285);
double r2504292 = r2504290 / r2504291;
double r2504293 = exp(r2504292);
double r2504294 = log(r2504293);
double r2504295 = 0.024496002194949438;
bool r2504296 = r2504285 <= r2504295;
double r2504297 = 5.0;
double r2504298 = pow(r2504285, r2504297);
double r2504299 = 0.004166666666666667;
double r2504300 = r2504298 * r2504299;
double r2504301 = 0.5;
double r2504302 = r2504301 * r2504285;
double r2504303 = r2504300 + r2504302;
double r2504304 = r2504285 * r2504285;
double r2504305 = r2504285 * r2504304;
double r2504306 = 0.041666666666666664;
double r2504307 = r2504305 * r2504306;
double r2504308 = r2504303 + r2504307;
double r2504309 = 1.0;
double r2504310 = r2504288 + r2504289;
double r2504311 = r2504309 / r2504310;
double r2504312 = r2504310 * r2504290;
double r2504313 = r2504312 / r2504291;
double r2504314 = r2504311 * r2504313;
double r2504315 = r2504296 ? r2504308 : r2504314;
double r2504316 = r2504287 ? r2504294 : r2504315;
return r2504316;
}




Bits error versus x
Results
| Original | 30.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.0196273269902602Initial program 0.9
rmApplied add-log-exp1.0
if -0.0196273269902602 < x < 0.024496002194949438Initial program 60.0
rmApplied clear-num60.0
Taylor expanded around 0 0.0
Simplified0.0
if 0.024496002194949438 < x Initial program 0.9
rmApplied clear-num1.0
rmApplied flip--1.4
Applied associate-/r/1.4
Applied *-un-lft-identity1.4
Applied times-frac1.4
Simplified1.1
Final simplification0.5
herbie shell --seed 2019171
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))