| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 3680 |
\[\log \left(x \cdot 2 + \left(\frac{-0.5}{x} + \frac{\frac{-0.125}{x \cdot x}}{x}\right)\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (log (+ (* x 2.0) (/ (+ (/ -0.125 x) (* x -0.5)) (* x x)))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return logf(((x * 2.0f) + (((-0.125f / x) + (x * -0.5f)) / (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.125e0) / x) + (x * (-0.5e0))) / (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(Float32(-0.125) / x) + Float32(x * Float32(-0.5))) / 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(2.0)) + (((single(-0.125) / x) + (x * single(-0.5))) / (x * x)))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(x \cdot 2 + \frac{\frac{-0.125}{x} + x \cdot -0.5}{x \cdot x}\right)
Results
| Original | 16.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
Initial program 16.0
Taylor expanded in x around inf 0.4
Simplified0.4
[Start]0.4 | \[ \log \left(2 \cdot x - \left(0.5 \cdot \frac{1}{x} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)
\] |
|---|---|
*-commutative [=>]0.4 | \[ \log \left(\color{blue}{x \cdot 2} - \left(0.5 \cdot \frac{1}{x} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)
\] |
associate-*r/ [=>]0.4 | \[ \log \left(x \cdot 2 - \left(\color{blue}{\frac{0.5 \cdot 1}{x}} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)
\] |
metadata-eval [=>]0.4 | \[ \log \left(x \cdot 2 - \left(\frac{\color{blue}{0.5}}{x} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)
\] |
associate-*r/ [=>]0.4 | \[ \log \left(x \cdot 2 - \left(\frac{0.5}{x} + \color{blue}{\frac{0.125 \cdot 1}{{x}^{3}}}\right)\right)
\] |
metadata-eval [=>]0.4 | \[ \log \left(x \cdot 2 - \left(\frac{0.5}{x} + \frac{\color{blue}{0.125}}{{x}^{3}}\right)\right)
\] |
Applied egg-rr0.4
Applied egg-rr0.4
Simplified0.4
[Start]0.4 | \[ \log \left(x \cdot 2 - \frac{0.5 \cdot x + x \cdot \frac{0.125}{x \cdot x}}{x \cdot x}\right)
\] |
|---|---|
*-commutative [=>]0.4 | \[ \log \left(x \cdot 2 - \frac{\color{blue}{x \cdot 0.5} + x \cdot \frac{0.125}{x \cdot x}}{x \cdot x}\right)
\] |
distribute-lft-out [=>]0.4 | \[ \log \left(x \cdot 2 - \frac{\color{blue}{x \cdot \left(0.5 + \frac{0.125}{x \cdot x}\right)}}{x \cdot x}\right)
\] |
Applied egg-rr0.4
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 3680 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 3424 |
| Alternative 3 | |
|---|---|
| Error | 1.0 |
| Cost | 3296 |
herbie shell --seed 2023016
(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)))))