| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 3552 |
\[\mathsf{log1p}\left(\left(x \cdot 2 + 1\right) + \left(-2 + \frac{-0.5}{x}\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 (* x x)) x)))))
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 / (x * x)) / 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(((x * 2.0e0) - ((0.5e0 / x) + ((0.125e0 / (x * x)) / x))))
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(Float32(0.125) / Float32(x * x)) / x)))) 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 * x)) / x)))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(x \cdot 2 - \left(\frac{0.5}{x} + \frac{\frac{0.125}{x \cdot x}}{x}\right)\right)
Results
| Original | 16.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.5 |
Initial program 16.1
Taylor expanded in x around inf 0.5
Simplified0.5
Applied egg-rr0.5
Applied egg-rr0.5
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 3552 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 3424 |
| Alternative 3 | |
|---|---|
| Error | 1.1 |
| Cost | 3360 |
| Alternative 4 | |
|---|---|
| Error | 1.1 |
| Cost | 3296 |
| Alternative 5 | |
|---|---|
| Error | 30.0 |
| Cost | 32 |
herbie shell --seed 2022343
(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)))))