| Alternative 1 | |
|---|---|
| Error | 98.7% |
| Cost | 3680.00 |
\[\log \left(x + \left(\left(x + \frac{-0.5}{x}\right) - \frac{\frac{0.125}{x}}{x \cdot x}\right)\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (log (+ x (+ (+ x (/ -0.5 x)) (+ (/ -0.125 (pow x 3.0)) (/ -0.0625 (pow x 5.0)))))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
return logf((x + ((x + (-0.5f / x)) + ((-0.125f / powf(x, 3.0f)) + (-0.0625f / powf(x, 5.0f))))));
}
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) / x)) + (((-0.125e0) / (x ** 3.0e0)) + ((-0.0625e0) / (x ** 5.0e0))))))
end function
function code(x) return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0))))) end
function code(x) return log(Float32(x + Float32(Float32(x + Float32(Float32(-0.5) / x)) + Float32(Float32(Float32(-0.125) / (x ^ Float32(3.0))) + Float32(Float32(-0.0625) / (x ^ Float32(5.0))))))) 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) / x)) + ((single(-0.125) / (x ^ single(3.0))) + (single(-0.0625) / (x ^ single(5.0))))))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(x + \left(\left(x + \frac{-0.5}{x}\right) + \left(\frac{-0.125}{{x}^{3}} + \frac{-0.0625}{{x}^{5}}\right)\right)\right)
Results
| Original | 49.3% |
|---|---|
| Target | 99.3% |
| Herbie | 98.8% |
Initial program 49.3
Taylor expanded in x around inf 98.8
Simplified98.8
[Start]98.8 | \[ \log \left(x + \left(x - \left(0.5 \cdot \frac{1}{x} + \left(0.0625 \cdot \frac{1}{{x}^{5}} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)\right)\right)
\] |
|---|---|
associate--r+ [=>]98.8 | \[ \log \left(x + \color{blue}{\left(\left(x - 0.5 \cdot \frac{1}{x}\right) - \left(0.0625 \cdot \frac{1}{{x}^{5}} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)}\right)
\] |
associate-*r/ [=>]98.8 | \[ \log \left(x + \left(\left(x - \color{blue}{\frac{0.5 \cdot 1}{x}}\right) - \left(0.0625 \cdot \frac{1}{{x}^{5}} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)\right)
\] |
metadata-eval [=>]98.8 | \[ \log \left(x + \left(\left(x - \frac{\color{blue}{0.5}}{x}\right) - \left(0.0625 \cdot \frac{1}{{x}^{5}} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)\right)
\] |
+-commutative [=>]98.8 | \[ \log \left(x + \left(\left(x - \frac{0.5}{x}\right) - \color{blue}{\left(0.125 \cdot \frac{1}{{x}^{3}} + 0.0625 \cdot \frac{1}{{x}^{5}}\right)}\right)\right)
\] |
associate-*r/ [=>]98.8 | \[ \log \left(x + \left(\left(x - \frac{0.5}{x}\right) - \left(\color{blue}{\frac{0.125 \cdot 1}{{x}^{3}}} + 0.0625 \cdot \frac{1}{{x}^{5}}\right)\right)\right)
\] |
metadata-eval [=>]98.8 | \[ \log \left(x + \left(\left(x - \frac{0.5}{x}\right) - \left(\frac{\color{blue}{0.125}}{{x}^{3}} + 0.0625 \cdot \frac{1}{{x}^{5}}\right)\right)\right)
\] |
associate-*r/ [=>]98.8 | \[ \log \left(x + \left(\left(x - \frac{0.5}{x}\right) - \left(\frac{0.125}{{x}^{3}} + \color{blue}{\frac{0.0625 \cdot 1}{{x}^{5}}}\right)\right)\right)
\] |
metadata-eval [=>]98.8 | \[ \log \left(x + \left(\left(x - \frac{0.5}{x}\right) - \left(\frac{0.125}{{x}^{3}} + \frac{\color{blue}{0.0625}}{{x}^{5}}\right)\right)\right)
\] |
Final simplification98.8
| Alternative 1 | |
|---|---|
| Error | 98.7% |
| Cost | 3680.00 |
| Alternative 2 | |
|---|---|
| Error | 98.3% |
| Cost | 3488.00 |
| Alternative 3 | |
|---|---|
| Error | 98.3% |
| Cost | 3424.00 |
| Alternative 4 | |
|---|---|
| Error | 97.1% |
| Cost | 3296.00 |
| Alternative 5 | |
|---|---|
| Error | 44.2% |
| Cost | 3232.00 |
| Alternative 6 | |
|---|---|
| Error | 6.1% |
| Cost | 32.00 |
herbie shell --seed 2023097
(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)))))