| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 3648 |
\[-\log \left(\frac{\frac{0.125}{x}}{x \cdot x} + 0.5 \cdot \frac{1}{x}\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (log (+ x (* (sqrt (+ x 1.0)) (sqrt (+ x -1.0))))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return logf((x + (sqrtf((x + 1.0f)) * sqrtf((x + -1.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 + (sqrt((x + 1.0e0)) * sqrt((x + (-1.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(x + Float32(sqrt(Float32(x + Float32(1.0))) * sqrt(Float32(x + Float32(-1.0)))))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - single(1.0))))); end
function tmp = code(x) tmp = log((x + (sqrt((x + single(1.0))) * sqrt((x + single(-1.0)))))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(x + \sqrt{x + 1} \cdot \sqrt{x + -1}\right)
Results
| Original | 16.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
Initial program 16.2
Applied egg-rr0.3
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 3648 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 3488 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 3424 |
| Alternative 4 | |
|---|---|
| Error | 0.8 |
| Cost | 3328 |
| Alternative 5 | |
|---|---|
| Error | 1.0 |
| Cost | 3296 |
| Alternative 6 | |
|---|---|
| Error | 30.0 |
| Cost | 32 |
herbie shell --seed 2023034
(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)))))