| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 3488 |
\[\mathsf{log1p}\left(\left(x + x\right) + \left(\frac{-0.5}{x} + -1\right)\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (log (+ (+ x (/ -0.5 x)) (+ x (/ -0.25 (* (- x (/ -0.5 x)) (* x x)))))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return logf(((x + (-0.5f / x)) + (x + (-0.25f / ((x - (-0.5f / 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 + ((-0.5e0) / x)) + (x + ((-0.25e0) / ((x - ((-0.5e0) / 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(Float32(-0.5) / x)) + Float32(x + Float32(Float32(-0.25) / Float32(Float32(x - Float32(Float32(-0.5) / x)) * Float32(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(-0.5) / x)) + (x + (single(-0.25) / ((x - (single(-0.5) / x)) * (x * x)))))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(\left(x + \frac{-0.5}{x}\right) + \left(x + \frac{-0.25}{\left(x - \frac{-0.5}{x}\right) \cdot \left(x \cdot x\right)}\right)\right)
Results
| Original | 16.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.6 |
Initial program 16.0
Taylor expanded in x around inf 0.6
Simplified0.6
[Start]0.6 | \[ \log \left(x + \left(x - 0.5 \cdot \frac{1}{x}\right)\right)
\] |
|---|---|
associate-*r/ [=>]0.6 | \[ \log \left(x + \left(x - \color{blue}{\frac{0.5 \cdot 1}{x}}\right)\right)
\] |
metadata-eval [=>]0.6 | \[ \log \left(x + \left(x - \frac{\color{blue}{0.5}}{x}\right)\right)
\] |
Applied egg-rr0.6
Taylor expanded in x around inf 0.6
Simplified0.6
[Start]0.6 | \[ \log \left(\left(x - 0.5 \cdot \frac{1}{x}\right) - \left(\frac{0.25}{\left(x + \frac{0.5}{x}\right) \cdot \left(x \cdot x\right)} - x\right)\right)
\] |
|---|---|
associate-*r/ [=>]0.6 | \[ \log \left(\left(x - \color{blue}{\frac{0.5 \cdot 1}{x}}\right) - \left(\frac{0.25}{\left(x + \frac{0.5}{x}\right) \cdot \left(x \cdot x\right)} - x\right)\right)
\] |
metadata-eval [=>]0.6 | \[ \log \left(\left(x - \frac{\color{blue}{0.5}}{x}\right) - \left(\frac{0.25}{\left(x + \frac{0.5}{x}\right) \cdot \left(x \cdot x\right)} - x\right)\right)
\] |
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 3488 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 3424 |
| Alternative 3 | |
|---|---|
| Error | 1.0 |
| Cost | 3296 |
| Alternative 4 | |
|---|---|
| Error | 17.9 |
| Cost | 3232 |
| Alternative 5 | |
|---|---|
| Error | 30.0 |
| Cost | 32 |
herbie shell --seed 2023066
(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)))))