\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;x \le -0.02175733191988275458395030170777317835018 \lor \neg \left(x \le 0.02301026064809699039903634343318117316812\right):\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\left(\cos x \cdot \frac{\cos x \cdot \cos x - 1 \cdot 1}{\cos x - 1} + 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 r35222 = 1.0;
double r35223 = x;
double r35224 = cos(r35223);
double r35225 = r35222 - r35224;
double r35226 = sin(r35223);
double r35227 = r35225 / r35226;
return r35227;
}
double f(double x) {
double r35228 = x;
double r35229 = -0.021757331919882755;
bool r35230 = r35228 <= r35229;
double r35231 = 0.02301026064809699;
bool r35232 = r35228 <= r35231;
double r35233 = !r35232;
bool r35234 = r35230 || r35233;
double r35235 = 1.0;
double r35236 = 3.0;
double r35237 = pow(r35235, r35236);
double r35238 = cos(r35228);
double r35239 = pow(r35238, r35236);
double r35240 = r35237 - r35239;
double r35241 = r35238 * r35238;
double r35242 = r35235 * r35235;
double r35243 = r35241 - r35242;
double r35244 = r35238 - r35235;
double r35245 = r35243 / r35244;
double r35246 = r35238 * r35245;
double r35247 = r35246 + r35242;
double r35248 = sin(r35228);
double r35249 = r35247 * r35248;
double r35250 = r35240 / r35249;
double r35251 = 0.041666666666666664;
double r35252 = pow(r35228, r35236);
double r35253 = r35251 * r35252;
double r35254 = 0.004166666666666667;
double r35255 = 5.0;
double r35256 = pow(r35228, r35255);
double r35257 = r35254 * r35256;
double r35258 = 0.5;
double r35259 = r35258 * r35228;
double r35260 = r35257 + r35259;
double r35261 = r35253 + r35260;
double r35262 = r35234 ? r35250 : r35261;
return r35262;
}




Bits error versus x
Results
| Original | 30.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if x < -0.021757331919882755 or 0.02301026064809699 < x Initial program 0.9
rmApplied flip3--1.1
Applied associate-/l/1.1
Simplified1.1
rmApplied add-sqr-sqrt1.1
rmApplied flip-+1.1
Applied sqrt-div64.0
Applied flip-+64.0
Applied sqrt-div64.0
Applied frac-times64.0
Simplified64.0
Simplified1.1
if -0.021757331919882755 < x < 0.02301026064809699Initial program 59.9
Taylor expanded around 0 0.0
Final simplification0.5
herbie shell --seed 2019291
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))