\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.0246265005946238076 \lor \neg \left(x \le 0.023818992858148251\right):\\
\;\;\;\;\frac{{1}^{3} - \sqrt[3]{{\left(\cos x\right)}^{9}}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \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 r301 = 1.0;
double r302 = x;
double r303 = cos(r302);
double r304 = r301 - r303;
double r305 = sin(r302);
double r306 = r304 / r305;
return r306;
}
double f(double x) {
double r307 = x;
double r308 = -0.024626500594623808;
bool r309 = r307 <= r308;
double r310 = 0.02381899285814825;
bool r311 = r307 <= r310;
double r312 = !r311;
bool r313 = r309 || r312;
double r314 = 1.0;
double r315 = 3.0;
double r316 = pow(r314, r315);
double r317 = cos(r307);
double r318 = 9.0;
double r319 = pow(r317, r318);
double r320 = cbrt(r319);
double r321 = r316 - r320;
double r322 = r317 + r314;
double r323 = r317 * r322;
double r324 = r314 * r314;
double r325 = r323 + r324;
double r326 = sin(r307);
double r327 = r325 * r326;
double r328 = r321 / r327;
double r329 = 0.041666666666666664;
double r330 = pow(r307, r315);
double r331 = r329 * r330;
double r332 = 0.004166666666666667;
double r333 = 5.0;
double r334 = pow(r307, r333);
double r335 = r332 * r334;
double r336 = 0.5;
double r337 = r336 * r307;
double r338 = r335 + r337;
double r339 = r331 + r338;
double r340 = r313 ? r328 : r339;
return r340;
}




Bits error versus x
Results
| Original | 29.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if x < -0.024626500594623808 or 0.02381899285814825 < x Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-cbrt-cube1.1
Simplified1.1
rmApplied pow-pow1.1
Simplified1.1
if -0.024626500594623808 < x < 0.02381899285814825Initial program 59.8
Taylor expanded around 0 0.0
Final simplification0.6
herbie shell --seed 2020025
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))