\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.0444958089144920146:\\
\;\;\;\;\frac{\mathsf{fma}\left(1, 1, \cos x \cdot \left(\cos x + 1\right)\right) \cdot \left(1 - \cos x\right)}{\mathsf{fma}\left(1, 1, \mathsf{fma}\left(\cos x, \cos x, 1 \cdot \cos x\right)\right) \cdot \sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 0.0033326395732868408:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{24}, {x}^{3}, \mathsf{fma}\left(\frac{1}{240}, {x}^{5}, \frac{1}{2} \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{1}^{3} - \mathsf{log1p}\left(\mathsf{expm1}\left({\left(\cos x\right)}^{3}\right)\right)}{\mathsf{fma}\left(1, 1, \mathsf{fma}\left(\cos x, \cos x, 1 \cdot \cos x\right)\right) \cdot \sin x}\\
\end{array}double f(double x) {
double r78328 = 1.0;
double r78329 = x;
double r78330 = cos(r78329);
double r78331 = r78328 - r78330;
double r78332 = sin(r78329);
double r78333 = r78331 / r78332;
return r78333;
}
double f(double x) {
double r78334 = 1.0;
double r78335 = x;
double r78336 = cos(r78335);
double r78337 = r78334 - r78336;
double r78338 = sin(r78335);
double r78339 = r78337 / r78338;
double r78340 = -0.044495808914492015;
bool r78341 = r78339 <= r78340;
double r78342 = r78336 + r78334;
double r78343 = r78336 * r78342;
double r78344 = fma(r78334, r78334, r78343);
double r78345 = r78344 * r78337;
double r78346 = r78334 * r78336;
double r78347 = fma(r78336, r78336, r78346);
double r78348 = fma(r78334, r78334, r78347);
double r78349 = r78348 * r78338;
double r78350 = r78345 / r78349;
double r78351 = 0.003332639573286841;
bool r78352 = r78339 <= r78351;
double r78353 = 0.041666666666666664;
double r78354 = 3.0;
double r78355 = pow(r78335, r78354);
double r78356 = 0.004166666666666667;
double r78357 = 5.0;
double r78358 = pow(r78335, r78357);
double r78359 = 0.5;
double r78360 = r78359 * r78335;
double r78361 = fma(r78356, r78358, r78360);
double r78362 = fma(r78353, r78355, r78361);
double r78363 = pow(r78334, r78354);
double r78364 = pow(r78336, r78354);
double r78365 = expm1(r78364);
double r78366 = log1p(r78365);
double r78367 = r78363 - r78366;
double r78368 = r78367 / r78349;
double r78369 = r78352 ? r78362 : r78368;
double r78370 = r78341 ? r78350 : r78369;
return r78370;
}




Bits error versus x
| Original | 29.4 |
|---|---|
| Target | 0.0 |
| Herbie | 1.0 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.044495808914492015Initial program 0.7
rmApplied flip3--0.8
Applied associate-/l/0.8
Simplified0.8
rmApplied difference-cubes0.8
Simplified0.8
if -0.044495808914492015 < (/ (- 1.0 (cos x)) (sin x)) < 0.003332639573286841Initial program 59.0
Taylor expanded around 0 1.1
Simplified1.1
if 0.003332639573286841 < (/ (- 1.0 (cos x)) (sin x)) Initial program 0.9
rmApplied flip3--1.0
Applied associate-/l/1.0
Simplified1.0
rmApplied log1p-expm1-u1.0
Final simplification1.0
herbie shell --seed 2020025 +o rules:numerics
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))