\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02328095837562494524464185019496653694659 \lor \neg \left(x \le 0.02122713234710593005472034633385192137212\right):\\
\;\;\;\;\frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\sin x}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}\\
\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 r68190 = 1.0;
double r68191 = x;
double r68192 = cos(r68191);
double r68193 = r68190 - r68192;
double r68194 = sin(r68191);
double r68195 = r68193 / r68194;
return r68195;
}
double f(double x) {
double r68196 = x;
double r68197 = -0.023280958375624945;
bool r68198 = r68196 <= r68197;
double r68199 = 0.02122713234710593;
bool r68200 = r68196 <= r68199;
double r68201 = !r68200;
bool r68202 = r68198 || r68201;
double r68203 = 1.0;
double r68204 = 3.0;
double r68205 = pow(r68203, r68204);
double r68206 = cos(r68196);
double r68207 = pow(r68206, r68204);
double r68208 = r68205 - r68207;
double r68209 = sin(r68196);
double r68210 = r68208 / r68209;
double r68211 = r68206 + r68203;
double r68212 = r68206 * r68211;
double r68213 = r68203 * r68203;
double r68214 = r68212 + r68213;
double r68215 = r68210 / r68214;
double r68216 = 0.041666666666666664;
double r68217 = pow(r68196, r68204);
double r68218 = r68216 * r68217;
double r68219 = 0.004166666666666667;
double r68220 = 5.0;
double r68221 = pow(r68196, r68220);
double r68222 = r68219 * r68221;
double r68223 = 0.5;
double r68224 = r68223 * r68196;
double r68225 = r68222 + r68224;
double r68226 = r68218 + r68225;
double r68227 = r68202 ? r68215 : r68226;
return r68227;
}




Bits error versus x
Results
| Original | 29.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.023280958375624945Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-cbrt-cube1.1
Simplified1.1
if -0.023280958375624945 < x < 0.02122713234710593Initial program 59.8
Taylor expanded around 0 0.0
if 0.02122713234710593 < x Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied add-cube-cbrt1.2
Final simplification0.5
herbie shell --seed 2019308
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))