| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 3424 |
\[\log \left(x \cdot 2 + \frac{-0.5}{x}\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (- (log (+ (/ 0.125 (pow x 3.0)) (/ 0.5 x)))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return -logf(((0.125f / powf(x, 3.0f)) + (0.5f / x)));
}
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(((0.125e0 / (x ** 3.0e0)) + (0.5e0 / x)))
end function
function code(x) return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0))))) end
function code(x) return Float32(-log(Float32(Float32(Float32(0.125) / (x ^ Float32(3.0))) + Float32(Float32(0.5) / x)))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - single(1.0))))); end
function tmp = code(x) tmp = -log(((single(0.125) / (x ^ single(3.0))) + (single(0.5) / x))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
-\log \left(\frac{0.125}{{x}^{3}} + \frac{0.5}{x}\right)
Results
| Original | 16.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
Initial program 16.0
Applied egg-rr29.8
Simplified29.8
Taylor expanded in x around inf 0.4
Simplified0.4
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 3424 |
| Alternative 2 | |
|---|---|
| Error | 0.8 |
| Cost | 3328 |
| Alternative 3 | |
|---|---|
| Error | 1.0 |
| Cost | 3296 |
| Alternative 4 | |
|---|---|
| Error | 30.0 |
| Cost | 32 |
herbie shell --seed 2022328
(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)))))