\frac{1 - \cos x}{\sin x}
\frac{\sin \left(x \cdot 0.5\right)}{\cos \left(x \cdot 0.5\right)}
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (sin x)))
(FPCore (x) :precision binary64 (/ (sin (* x 0.5)) (cos (* x 0.5))))
double code(double x) {
return (1.0 - cos(x)) / sin(x);
}
double code(double x) {
return sin(x * 0.5) / cos(x * 0.5);
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
Initial program 30.3
Simplified0.3
Applied add-cube-cbrt_binary640.8
Applied pow3_binary640.8
Taylor expanded in x around inf 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 1991292424
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))