| Alternative 1 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 6784 |
\[\log \left(x \cdot 2 - \left(\frac{0.5}{x} + \frac{0.125}{{x}^{3}}\right)\right)
\]

(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (log (- (* x 2.0) (+ (/ 0.5 x) (/ 0.125 (pow x 3.0))))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return logf(((x * 2.0f) - ((0.5f / x) + (0.125f / powf(x, 3.0f)))));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log((x + sqrt(((x * x) - 1.0e0))))
end function
real(4) function code(x)
real(4), intent (in) :: x
code = log(((x * 2.0e0) - ((0.5e0 / x) + (0.125e0 / (x ** 3.0e0)))))
end function
function code(x) return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0))))) end
function code(x) return log(Float32(Float32(x * Float32(2.0)) - Float32(Float32(Float32(0.5) / x) + Float32(Float32(0.125) / (x ^ Float32(3.0)))))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - single(1.0))))); end
function tmp = code(x) tmp = log(((x * single(2.0)) - ((single(0.5) / x) + (single(0.125) / (x ^ single(3.0)))))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(x \cdot 2 - \left(\frac{0.5}{x} + \frac{0.125}{{x}^{3}}\right)\right)
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 53.2% |
|---|---|
| Target | 99.0% |
| Herbie | 98.4% |
Initial program 56.1%
Taylor expanded in x around inf 97.5%
Simplified97.5%
[Start]97.5% | \[ \log \left(2 \cdot x - \left(0.5 \cdot \frac{1}{x} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)
\] |
|---|---|
*-commutative [=>]97.5% | \[ \log \left(\color{blue}{x \cdot 2} - \left(0.5 \cdot \frac{1}{x} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)
\] |
associate-*r/ [=>]97.5% | \[ \log \left(x \cdot 2 - \left(\color{blue}{\frac{0.5 \cdot 1}{x}} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)
\] |
metadata-eval [=>]97.5% | \[ \log \left(x \cdot 2 - \left(\frac{\color{blue}{0.5}}{x} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)
\] |
associate-*r/ [=>]97.5% | \[ \log \left(x \cdot 2 - \left(\frac{0.5}{x} + \color{blue}{\frac{0.125 \cdot 1}{{x}^{3}}}\right)\right)
\] |
metadata-eval [=>]97.5% | \[ \log \left(x \cdot 2 - \left(\frac{0.5}{x} + \frac{\color{blue}{0.125}}{{x}^{3}}\right)\right)
\] |
Final simplification97.5%
| Alternative 1 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 6784 |
| Alternative 2 | |
|---|---|
| Accuracy | 97.9% |
| Cost | 3424 |
| Alternative 3 | |
|---|---|
| Accuracy | 96.7% |
| Cost | 3360 |
| Alternative 4 | |
|---|---|
| Accuracy | 44.2% |
| Cost | 3296 |
| Alternative 5 | |
|---|---|
| Accuracy | 96.6% |
| Cost | 3296 |
| Alternative 6 | |
|---|---|
| Accuracy | 20.8% |
| Cost | 32 |
| Alternative 7 | |
|---|---|
| Accuracy | 22.2% |
| Cost | 32 |
| Alternative 8 | |
|---|---|
| Accuracy | 22.3% |
| Cost | 32 |
herbie shell --seed 2023269
(FPCore (x)
:name "Rust f32::acosh"
:precision binary32
:pre (>= x 1.0)
:herbie-target
(log (+ x (* (sqrt (- x 1.0)) (sqrt (+ x 1.0)))))
(log (+ x (sqrt (- (* x x) 1.0)))))