| Alternative 1 | |
|---|---|
| Error | 1.0 |
| Cost | 3296 |
\[\log \left(x + x\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (log (- (+ x x) (* 0.5 (/ 1.0 x)))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return logf(((x + x) - (0.5f * (1.0f / 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 + x) - (0.5e0 * (1.0e0 / 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 + x) - Float32(Float32(0.5) * Float32(Float32(1.0) / x)))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - single(1.0))))); end
function tmp = code(x) tmp = log(((x + x) - (single(0.5) * (single(1.0) / x)))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(\left(x + x\right) - 0.5 \cdot \frac{1}{x}\right)
Results
| Original | 16.2 |
|---|---|
| Target | 0.2 |
| Herbie | 0.6 |
Initial program 16.2
Taylor expanded in x around inf 0.6
Simplified0.6
[Start]0.6 | \[ \log \left(2 \cdot x - 0.5 \cdot \frac{1}{x}\right)
\] |
|---|---|
metadata-eval [<=]0.6 | \[ \log \left(\color{blue}{\left(1 + 1\right)} \cdot x - 0.5 \cdot \frac{1}{x}\right)
\] |
rational.json-simplify-7 [<=]0.6 | \[ \log \left(\left(1 + 1\right) \cdot \color{blue}{\frac{x}{1}} - 0.5 \cdot \frac{1}{x}\right)
\] |
rational.json-simplify-30 [=>]0.6 | \[ \log \left(\color{blue}{\left(x + \frac{x}{1}\right)} - 0.5 \cdot \frac{1}{x}\right)
\] |
rational.json-simplify-7 [=>]0.6 | \[ \log \left(\left(x + \color{blue}{x}\right) - 0.5 \cdot \frac{1}{x}\right)
\] |
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 1.0 |
| Cost | 3296 |
herbie shell --seed 2023074
(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)))))