\frac{1 - \cos x}{\sin x}\tan \left(\frac{x}{2}\right)(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (sin x)))
(FPCore (x) :precision binary64 (tan (/ x 2.0)))
double code(double x) {
return (1.0 - cos(x)) / sin(x);
}
double code(double x) {
return tan(x / 2.0);
}







Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
| Alternative 1 | |
|---|---|
| Error | 29.0 |
| Cost | 1218 |
| Alternative 2 | |
|---|---|
| Error | 29.0 |
| Cost | 834 |
| Alternative 3 | |
|---|---|
| Error | 59.5 |
| Cost | 64 |


Initial program 30.3
rmApplied *-un-lft-identity_binary64_41930.3
Applied *-un-lft-identity_binary64_41930.3
Applied times-frac_binary64_42530.3
Simplified30.3
Simplified0.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2021040
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))