| Alternative 1 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 3520 |
\[0.5 \cdot \left(2 \cdot x + 0.6666666666666666 \cdot {x}^{3}\right)
\]

(FPCore (x) :precision binary32 (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))
(FPCore (x) :precision binary32 (* 0.5 (+ (* 2.0 x) (* 0.6666666666666666 (pow x 3.0)))))
float code(float x) {
return 0.5f * log1pf(((2.0f * x) / (1.0f - x)));
}
float code(float x) {
return 0.5f * ((2.0f * x) + (0.6666666666666666f * powf(x, 3.0f)));
}
function code(x) return Float32(Float32(0.5) * log1p(Float32(Float32(Float32(2.0) * x) / Float32(Float32(1.0) - x)))) end
function code(x) return Float32(Float32(0.5) * Float32(Float32(Float32(2.0) * x) + Float32(Float32(0.6666666666666666) * (x ^ Float32(3.0))))) end
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
0.5 \cdot \left(2 \cdot x + 0.6666666666666666 \cdot {x}^{3}\right)
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 99.8%
Simplified99.2%
[Start]99.8% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
\] |
|---|---|
associate-/l* [=>]99.2% | \[ 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{\frac{1 - x}{x}}}\right)
\] |
Taylor expanded in x around 0 99.9%
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 3520 |
| Alternative 2 | |
|---|---|
| Accuracy | 96.6% |
| Cost | 3488 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 3488 |
| Alternative 4 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 3488 |
| Alternative 5 | |
|---|---|
| Accuracy | 93.2% |
| Cost | 3360 |
| Alternative 6 | |
|---|---|
| Accuracy | 7.7% |
| Cost | 32 |
herbie shell --seed 2023165
(FPCore (x)
:name "Rust f32::atanh"
:precision binary32
(* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))