\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.015504801539486723 \lor \neg \left(x \le 0.024127924279373096\right):\\
\;\;\;\;\frac{\frac{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}{\frac{\cos x \cdot \frac{{\left(\cos x\right)}^{2} - 1 \cdot 1}{\cos x - 1} + 1 \cdot 1}{e^{\log \left(1 - \cos x\right)}}}}{\sin x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\end{array}double f(double x) {
double r164340 = 1.0;
double r164341 = x;
double r164342 = cos(r164341);
double r164343 = r164340 - r164342;
double r164344 = sin(r164341);
double r164345 = r164343 / r164344;
return r164345;
}
double f(double x) {
double r164346 = x;
double r164347 = -0.015504801539486723;
bool r164348 = r164346 <= r164347;
double r164349 = 0.024127924279373096;
bool r164350 = r164346 <= r164349;
double r164351 = !r164350;
bool r164352 = r164348 || r164351;
double r164353 = 1.0;
double r164354 = r164353 * r164353;
double r164355 = cos(r164346);
double r164356 = r164355 * r164355;
double r164357 = r164353 * r164355;
double r164358 = r164356 + r164357;
double r164359 = r164354 + r164358;
double r164360 = 2.0;
double r164361 = pow(r164355, r164360);
double r164362 = r164361 - r164354;
double r164363 = r164355 - r164353;
double r164364 = r164362 / r164363;
double r164365 = r164355 * r164364;
double r164366 = r164365 + r164354;
double r164367 = r164353 - r164355;
double r164368 = log(r164367);
double r164369 = exp(r164368);
double r164370 = r164366 / r164369;
double r164371 = r164359 / r164370;
double r164372 = sin(r164346);
double r164373 = r164371 / r164372;
double r164374 = 0.041666666666666664;
double r164375 = 3.0;
double r164376 = pow(r164346, r164375);
double r164377 = r164374 * r164376;
double r164378 = 0.004166666666666667;
double r164379 = 5.0;
double r164380 = pow(r164346, r164379);
double r164381 = r164378 * r164380;
double r164382 = 0.5;
double r164383 = r164382 * r164346;
double r164384 = r164381 + r164383;
double r164385 = r164377 + r164384;
double r164386 = r164352 ? r164373 : r164385;
return r164386;
}




Bits error versus x
Results
| Original | 30.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.015504801539486723 or 0.024127924279373096 < x Initial program 0.9
rmApplied flip3--1.0
Simplified1.1
rmApplied difference-cubes1.0
Applied associate-/l*1.0
rmApplied add-exp-log1.0
rmApplied flip-+1.0
Simplified1.0
if -0.015504801539486723 < x < 0.024127924279373096Initial program 59.9
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2020020
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))