| Alternative 1 | |
|---|---|
| Accuracy | 98.2% |
| Cost | 3424 |
\[\log \left(x + \left(x + \frac{-0.5}{x}\right)\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (+ (log 2.0) (log x)))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return logf(2.0f) + logf(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(2.0e0) + log(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(2.0)) + log(x)) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - single(1.0))))); end
function tmp = code(x) tmp = log(single(2.0)) + log(x); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log 2 + \log x
Results
| Original | 49.7% |
|---|---|
| Target | 99.2% |
| Herbie | 96.8% |
Initial program 49.7%
Taylor expanded in x around inf 96.8%
Simplified96.8%
[Start]96.8 | \[ \log 2 + -1 \cdot \log \left(\frac{1}{x}\right)
\] |
|---|---|
mul-1-neg [=>]96.8 | \[ \log 2 + \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)}
\] |
log-rec [=>]96.8 | \[ \log 2 + \left(-\color{blue}{\left(-\log x\right)}\right)
\] |
remove-double-neg [=>]96.8 | \[ \log 2 + \color{blue}{\log x}
\] |
Final simplification96.8%
| Alternative 1 | |
|---|---|
| Accuracy | 98.2% |
| Cost | 3424 |
| Alternative 2 | |
|---|---|
| Accuracy | 96.9% |
| Cost | 3296 |
| Alternative 3 | |
|---|---|
| Accuracy | 6.1% |
| Cost | 32 |
| Alternative 4 | |
|---|---|
| Accuracy | 24.4% |
| Cost | 32 |
| Alternative 5 | |
|---|---|
| Accuracy | 29.0% |
| Cost | 32 |
herbie shell --seed 2023138
(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)))))