| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 3808 |
\[\log \left(\left(\frac{-0.5}{x} + \frac{-0.25}{\left(x \cdot x\right) \cdot \left(x + \frac{0.5}{x}\right)}\right) + 2 \cdot x\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (+ (log 2.0) (+ (log x) (/ -0.25 (* x x)))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return logf(2.0f) + (logf(x) + (-0.25f / (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(2.0e0) + (log(x) + ((-0.25e0) / (x * 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)) + Float32(log(x) + Float32(Float32(-0.25) / Float32(x * 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) + (single(-0.25) / (x * x))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log 2 + \left(\log x + \frac{-0.25}{x \cdot x}\right)
Results
| Original | 15.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.6 |
Initial program 15.8
Taylor expanded in x around inf 0.6
Simplified0.6
[Start]0.6 | \[ \left(-1 \cdot \log \left(\frac{1}{x}\right) + \log 2\right) - 0.25 \cdot \frac{1}{{x}^{2}}
\] |
|---|---|
cancel-sign-sub-inv [=>]0.6 | \[ \color{blue}{\left(-1 \cdot \log \left(\frac{1}{x}\right) + \log 2\right) + \left(-0.25\right) \cdot \frac{1}{{x}^{2}}}
\] |
+-commutative [=>]0.6 | \[ \color{blue}{\left(\log 2 + -1 \cdot \log \left(\frac{1}{x}\right)\right)} + \left(-0.25\right) \cdot \frac{1}{{x}^{2}}
\] |
associate-+l+ [=>]0.6 | \[ \color{blue}{\log 2 + \left(-1 \cdot \log \left(\frac{1}{x}\right) + \left(-0.25\right) \cdot \frac{1}{{x}^{2}}\right)}
\] |
mul-1-neg [=>]0.6 | \[ \log 2 + \left(\color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)} + \left(-0.25\right) \cdot \frac{1}{{x}^{2}}\right)
\] |
log-rec [=>]0.6 | \[ \log 2 + \left(\left(-\color{blue}{\left(-\log x\right)}\right) + \left(-0.25\right) \cdot \frac{1}{{x}^{2}}\right)
\] |
remove-double-neg [=>]0.6 | \[ \log 2 + \left(\color{blue}{\log x} + \left(-0.25\right) \cdot \frac{1}{{x}^{2}}\right)
\] |
unpow2 [=>]0.6 | \[ \log 2 + \left(\log x + \left(-0.25\right) \cdot \frac{1}{\color{blue}{x \cdot x}}\right)
\] |
associate-*r/ [=>]0.6 | \[ \log 2 + \left(\log x + \color{blue}{\frac{\left(-0.25\right) \cdot 1}{x \cdot x}}\right)
\] |
metadata-eval [=>]0.6 | \[ \log 2 + \left(\log x + \frac{\color{blue}{-0.25} \cdot 1}{x \cdot x}\right)
\] |
metadata-eval [=>]0.6 | \[ \log 2 + \left(\log x + \frac{\color{blue}{-0.25}}{x \cdot x}\right)
\] |
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 3808 |
| Alternative 2 | |
|---|---|
| Error | 0.5 |
| Cost | 3424 |
| Alternative 3 | |
|---|---|
| Error | 0.9 |
| Cost | 3296 |
| Alternative 4 | |
|---|---|
| Error | 24.2 |
| Cost | 3232 |
| Alternative 5 | |
|---|---|
| Error | 24.2 |
| Cost | 3232 |
| Alternative 6 | |
|---|---|
| Error | 17.9 |
| Cost | 3232 |
| Alternative 7 | |
|---|---|
| Error | 30.0 |
| Cost | 32 |
herbie shell --seed 2023039
(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)))))