\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02231715051571105112859783048406825400889:\\
\;\;\;\;\frac{{1}^{3} - \frac{\sqrt[3]{\left(\cos x + \cos x \cdot \cos \left(x + x\right)\right) \cdot \left(\left(\cos x + \cos x \cdot \cos \left(x + x\right)\right) \cdot \left(\cos x + \cos x \cdot \cos \left(x + x\right)\right)\right)}}{\sqrt[3]{8}}}{\left(1 \cdot \left(1 + \cos x\right) + \cos x \cdot \cos x\right) \cdot \sin x}\\
\mathbf{elif}\;x \le 0.02105783752125852878456235828252829378471:\\
\;\;\;\;\left(0.5 + \left(x \cdot x\right) \cdot 0.04166666666666667129259593593815225176513\right) \cdot x + 0.004166666666666666608842550800773096852936 \cdot {x}^{5}\\
\mathbf{else}:\\
\;\;\;\;\frac{{1}^{3} - \sqrt[3]{\left(\left(\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right)\right) \cdot \left(\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right)\right)\right) \cdot \cos x}}{\left(\cos x \cdot \cos x + 1 \cdot \frac{1 \cdot 1 - \cos x \cdot \cos x}{1 - \cos x}\right) \cdot \sin x}\\
\end{array}double f(double x) {
double r3517322 = 1.0;
double r3517323 = x;
double r3517324 = cos(r3517323);
double r3517325 = r3517322 - r3517324;
double r3517326 = sin(r3517323);
double r3517327 = r3517325 / r3517326;
return r3517327;
}
double f(double x) {
double r3517328 = x;
double r3517329 = -0.02231715051571105;
bool r3517330 = r3517328 <= r3517329;
double r3517331 = 1.0;
double r3517332 = 3.0;
double r3517333 = pow(r3517331, r3517332);
double r3517334 = cos(r3517328);
double r3517335 = r3517328 + r3517328;
double r3517336 = cos(r3517335);
double r3517337 = r3517334 * r3517336;
double r3517338 = r3517334 + r3517337;
double r3517339 = r3517338 * r3517338;
double r3517340 = r3517338 * r3517339;
double r3517341 = cbrt(r3517340);
double r3517342 = 8.0;
double r3517343 = cbrt(r3517342);
double r3517344 = r3517341 / r3517343;
double r3517345 = r3517333 - r3517344;
double r3517346 = r3517331 + r3517334;
double r3517347 = r3517331 * r3517346;
double r3517348 = r3517334 * r3517334;
double r3517349 = r3517347 + r3517348;
double r3517350 = sin(r3517328);
double r3517351 = r3517349 * r3517350;
double r3517352 = r3517345 / r3517351;
double r3517353 = 0.02105783752125853;
bool r3517354 = r3517328 <= r3517353;
double r3517355 = 0.5;
double r3517356 = r3517328 * r3517328;
double r3517357 = 0.04166666666666667;
double r3517358 = r3517356 * r3517357;
double r3517359 = r3517355 + r3517358;
double r3517360 = r3517359 * r3517328;
double r3517361 = 0.004166666666666667;
double r3517362 = 5.0;
double r3517363 = pow(r3517328, r3517362);
double r3517364 = r3517361 * r3517363;
double r3517365 = r3517360 + r3517364;
double r3517366 = r3517348 * r3517348;
double r3517367 = r3517366 * r3517366;
double r3517368 = r3517367 * r3517334;
double r3517369 = cbrt(r3517368);
double r3517370 = r3517333 - r3517369;
double r3517371 = r3517331 * r3517331;
double r3517372 = r3517371 - r3517348;
double r3517373 = r3517331 - r3517334;
double r3517374 = r3517372 / r3517373;
double r3517375 = r3517331 * r3517374;
double r3517376 = r3517348 + r3517375;
double r3517377 = r3517376 * r3517350;
double r3517378 = r3517370 / r3517377;
double r3517379 = r3517354 ? r3517365 : r3517378;
double r3517380 = r3517330 ? r3517352 : r3517379;
return r3517380;
}




Bits error versus x
Results
| Original | 30.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.02231715051571105Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.1
rmApplied add-cbrt-cube1.1
Simplified1.1
rmApplied cos-mult1.2
Applied associate-*r/1.2
Applied cos-mult1.2
Applied cos-mult1.2
Applied frac-times1.2
Applied frac-times1.2
Applied associate-*l/1.2
Applied cbrt-div1.2
Simplified1.2
Simplified1.2
if -0.02231715051571105 < x < 0.02105783752125853Initial program 60.0
rmApplied div-sub60.0
Taylor expanded around 0 0.0
Simplified0.0
if 0.02105783752125853 < x Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-cbrt-cube1.1
Simplified1.1
rmApplied flip-+1.1
Final simplification0.6
herbie shell --seed 2019172
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))