| Alternative 1 | |
|---|---|
| Error | 1.88% |
| Cost | 3552 |
\[\log \left(\left(x + \frac{0.5}{x}\right) + \left(x + \frac{-1}{x}\right)\right)
\]
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary32 (let* ((t_0 (+ x (/ 0.5 x)))) (log (- (+ x (/ x (/ t_0 x))) (/ 0.25 (* t_0 (* x x)))))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
float code(float x) {
float t_0 = x + (0.5f / x);
return logf(((x + (x / (t_0 / x))) - (0.25f / (t_0 * (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
real(4) :: t_0
t_0 = x + (0.5e0 / x)
code = log(((x + (x / (t_0 / x))) - (0.25e0 / (t_0 * (x * x)))))
end function
function code(x) return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0))))) end
function code(x) t_0 = Float32(x + Float32(Float32(0.5) / x)) return log(Float32(Float32(x + Float32(x / Float32(t_0 / x))) - Float32(Float32(0.25) / Float32(t_0 * Float32(x * x))))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - single(1.0))))); end
function tmp = code(x) t_0 = x + (single(0.5) / x); tmp = log(((x + (x / (t_0 / x))) - (single(0.25) / (t_0 * (x * x))))); end
\log \left(x + \sqrt{x \cdot x - 1}\right)
\begin{array}{l}
t_0 := x + \frac{0.5}{x}\\
\log \left(\left(x + \frac{x}{\frac{t_0}{x}}\right) - \frac{0.25}{t_0 \cdot \left(x \cdot x\right)}\right)
\end{array}
Results
| Original | 50.71% |
|---|---|
| Target | 0.81% |
| Herbie | 1.89% |
Initial program 50.71
Taylor expanded in x around inf 1.88
Simplified1.88
[Start]1.88 | \[ \log \left(x + \left(x - 0.5 \cdot \frac{1}{x}\right)\right)
\] |
|---|---|
associate-*r/ [=>]1.88 | \[ \log \left(x + \left(x - \color{blue}{\frac{0.5 \cdot 1}{x}}\right)\right)
\] |
metadata-eval [=>]1.88 | \[ \log \left(x + \left(x - \frac{\color{blue}{0.5}}{x}\right)\right)
\] |
Applied egg-rr1.89
Final simplification1.89
| Alternative 1 | |
|---|---|
| Error | 1.88% |
| Cost | 3552 |
| Alternative 2 | |
|---|---|
| Error | 1.89% |
| Cost | 3552 |
| Alternative 3 | |
|---|---|
| Error | 1.88% |
| Cost | 3424 |
| Alternative 4 | |
|---|---|
| Error | 2.53% |
| Cost | 3328 |
| Alternative 5 | |
|---|---|
| Error | 3.26% |
| Cost | 3296 |
| Alternative 6 | |
|---|---|
| Error | 93.89% |
| Cost | 32 |
herbie shell --seed 2023090
(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)))))