| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 7360 |

(FPCore (x) :precision binary64 (log (+ x (sqrt (- (* x x) 1.0)))))
(FPCore (x) :precision binary64 (log (- (* 2.0 x) (/ (+ x (/ 0.25 x)) (* x (* 2.0 x))))))
double code(double x) {
return log((x + sqrt(((x * x) - 1.0))));
}
double code(double x) {
return log(((2.0 * x) - ((x + (0.25 / x)) / (x * (2.0 * x)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = log((x + sqrt(((x * x) - 1.0d0))))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = log(((2.0d0 * x) - ((x + (0.25d0 / x)) / (x * (2.0d0 * x)))))
end function
public static double code(double x) {
return Math.log((x + Math.sqrt(((x * x) - 1.0))));
}
public static double code(double x) {
return Math.log(((2.0 * x) - ((x + (0.25 / x)) / (x * (2.0 * x)))));
}
def code(x): return math.log((x + math.sqrt(((x * x) - 1.0))))
def code(x): return math.log(((2.0 * x) - ((x + (0.25 / x)) / (x * (2.0 * x)))))
function code(x) return log(Float64(x + sqrt(Float64(Float64(x * x) - 1.0)))) end
function code(x) return log(Float64(Float64(2.0 * x) - Float64(Float64(x + Float64(0.25 / x)) / Float64(x * Float64(2.0 * x))))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - 1.0)))); end
function tmp = code(x) tmp = log(((2.0 * x) - ((x + (0.25 / x)) / (x * (2.0 * x))))); end
code[x_] := N[Log[N[(x + N[Sqrt[N[(N[(x * x), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[Log[N[(N[(2.0 * x), $MachinePrecision] - N[(N[(x + N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(2 \cdot x - \frac{x + \frac{0.25}{x}}{x \cdot \left(2 \cdot x\right)}\right)
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 51.9% |
|---|---|
| Target | 99.9% |
| Herbie | 99.7% |
Initial program 50.8%
Taylor expanded in x around inf 99.6%
Taylor expanded in x around inf 99.6%
Simplified99.6%
[Start]99.6% | \[ \log \left(2 \cdot x - \left(0.125 \cdot \frac{1}{{x}^{3}} + 0.5 \cdot \frac{1}{x}\right)\right)
\] |
|---|---|
associate-*r/ [=>]99.6% | \[ \log \left(2 \cdot x - \left(\color{blue}{\frac{0.125 \cdot 1}{{x}^{3}}} + 0.5 \cdot \frac{1}{x}\right)\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \left(\frac{\color{blue}{0.125}}{{x}^{3}} + 0.5 \cdot \frac{1}{x}\right)\right)
\] |
associate-*r/ [=>]99.6% | \[ \log \left(2 \cdot x - \left(\frac{0.125}{{x}^{3}} + \color{blue}{\frac{0.5 \cdot 1}{x}}\right)\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \left(\frac{0.125}{{x}^{3}} + \frac{\color{blue}{0.5}}{x}\right)\right)
\] |
Applied egg-rr99.6%
[Start]99.6% | \[ \log \left(2 \cdot x - \left(\frac{0.125}{{x}^{3}} + \frac{0.5}{x}\right)\right)
\] |
|---|---|
metadata-eval [<=]99.6% | \[ \log \left(2 \cdot x - \left(\frac{\color{blue}{{0.5}^{3}}}{{x}^{3}} + \frac{0.5}{x}\right)\right)
\] |
cube-div [<=]99.6% | \[ \log \left(2 \cdot x - \left(\color{blue}{{\left(\frac{0.5}{x}\right)}^{3}} + \frac{0.5}{x}\right)\right)
\] |
cube-mult [=>]99.6% | \[ \log \left(2 \cdot x - \left(\color{blue}{\frac{0.5}{x} \cdot \left(\frac{0.5}{x} \cdot \frac{0.5}{x}\right)} + \frac{0.5}{x}\right)\right)
\] |
frac-times [=>]99.6% | \[ \log \left(2 \cdot x - \left(\frac{0.5}{x} \cdot \color{blue}{\frac{0.5 \cdot 0.5}{x \cdot x}} + \frac{0.5}{x}\right)\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \left(\frac{0.5}{x} \cdot \frac{\color{blue}{0.25}}{x \cdot x} + \frac{0.5}{x}\right)\right)
\] |
Applied egg-rr99.6%
[Start]99.6% | \[ \log \left(2 \cdot x - \left(\frac{0.5}{x} \cdot \frac{0.25}{x \cdot x} + \frac{0.5}{x}\right)\right)
\] |
|---|---|
+-commutative [=>]99.6% | \[ \log \left(2 \cdot x - \color{blue}{\left(\frac{0.5}{x} + \frac{0.5}{x} \cdot \frac{0.25}{x \cdot x}\right)}\right)
\] |
clear-num [=>]99.6% | \[ \log \left(2 \cdot x - \left(\color{blue}{\frac{1}{\frac{x}{0.5}}} + \frac{0.5}{x} \cdot \frac{0.25}{x \cdot x}\right)\right)
\] |
associate-*l/ [=>]99.6% | \[ \log \left(2 \cdot x - \left(\frac{1}{\frac{x}{0.5}} + \color{blue}{\frac{0.5 \cdot \frac{0.25}{x \cdot x}}{x}}\right)\right)
\] |
frac-add [=>]99.6% | \[ \log \left(2 \cdot x - \color{blue}{\frac{1 \cdot x + \frac{x}{0.5} \cdot \left(0.5 \cdot \frac{0.25}{x \cdot x}\right)}{\frac{x}{0.5} \cdot x}}\right)
\] |
*-un-lft-identity [<=]99.6% | \[ \log \left(2 \cdot x - \frac{\color{blue}{x} + \frac{x}{0.5} \cdot \left(0.5 \cdot \frac{0.25}{x \cdot x}\right)}{\frac{x}{0.5} \cdot x}\right)
\] |
div-inv [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \color{blue}{\left(x \cdot \frac{1}{0.5}\right)} \cdot \left(0.5 \cdot \frac{0.25}{x \cdot x}\right)}{\frac{x}{0.5} \cdot x}\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot \color{blue}{2}\right) \cdot \left(0.5 \cdot \frac{0.25}{x \cdot x}\right)}{\frac{x}{0.5} \cdot x}\right)
\] |
div-inv [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \left(0.5 \cdot \color{blue}{\left(0.25 \cdot \frac{1}{x \cdot x}\right)}\right)}{\frac{x}{0.5} \cdot x}\right)
\] |
associate-*r* [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \color{blue}{\left(\left(0.5 \cdot 0.25\right) \cdot \frac{1}{x \cdot x}\right)}}{\frac{x}{0.5} \cdot x}\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \left(\color{blue}{0.125} \cdot \frac{1}{x \cdot x}\right)}{\frac{x}{0.5} \cdot x}\right)
\] |
pow2 [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \left(0.125 \cdot \frac{1}{\color{blue}{{x}^{2}}}\right)}{\frac{x}{0.5} \cdot x}\right)
\] |
pow-flip [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \left(0.125 \cdot \color{blue}{{x}^{\left(-2\right)}}\right)}{\frac{x}{0.5} \cdot x}\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \left(0.125 \cdot {x}^{\color{blue}{-2}}\right)}{\frac{x}{0.5} \cdot x}\right)
\] |
div-inv [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \left(0.125 \cdot {x}^{-2}\right)}{\color{blue}{\left(x \cdot \frac{1}{0.5}\right)} \cdot x}\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \left(0.125 \cdot {x}^{-2}\right)}{\left(x \cdot \color{blue}{2}\right) \cdot x}\right)
\] |
Simplified99.6%
[Start]99.6% | \[ \log \left(2 \cdot x - \frac{x + \left(x \cdot 2\right) \cdot \left(0.125 \cdot {x}^{-2}\right)}{\left(x \cdot 2\right) \cdot x}\right)
\] |
|---|---|
*-commutative [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \color{blue}{\left(2 \cdot x\right)} \cdot \left(0.125 \cdot {x}^{-2}\right)}{\left(x \cdot 2\right) \cdot x}\right)
\] |
associate-*l* [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \color{blue}{2 \cdot \left(x \cdot \left(0.125 \cdot {x}^{-2}\right)\right)}}{\left(x \cdot 2\right) \cdot x}\right)
\] |
*-commutative [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \color{blue}{\left(\left(0.125 \cdot {x}^{-2}\right) \cdot x\right)}}{\left(x \cdot 2\right) \cdot x}\right)
\] |
associate-*l* [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \color{blue}{\left(0.125 \cdot \left({x}^{-2} \cdot x\right)\right)}}{\left(x \cdot 2\right) \cdot x}\right)
\] |
metadata-eval [<=]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \left(\color{blue}{\left(0.25 \cdot 0.5\right)} \cdot \left({x}^{-2} \cdot x\right)\right)}{\left(x \cdot 2\right) \cdot x}\right)
\] |
pow-plus [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \left(\left(0.25 \cdot 0.5\right) \cdot \color{blue}{{x}^{\left(-2 + 1\right)}}\right)}{\left(x \cdot 2\right) \cdot x}\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \left(\left(0.25 \cdot 0.5\right) \cdot {x}^{\color{blue}{-1}}\right)}{\left(x \cdot 2\right) \cdot x}\right)
\] |
unpow-1 [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \left(\left(0.25 \cdot 0.5\right) \cdot \color{blue}{\frac{1}{x}}\right)}{\left(x \cdot 2\right) \cdot x}\right)
\] |
associate-*r* [<=]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \color{blue}{\left(0.25 \cdot \left(0.5 \cdot \frac{1}{x}\right)\right)}}{\left(x \cdot 2\right) \cdot x}\right)
\] |
associate-*r/ [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \left(0.25 \cdot \color{blue}{\frac{0.5 \cdot 1}{x}}\right)}{\left(x \cdot 2\right) \cdot x}\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \left(0.25 \cdot \frac{\color{blue}{0.5}}{x}\right)}{\left(x \cdot 2\right) \cdot x}\right)
\] |
associate-*r/ [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \color{blue}{\frac{0.25 \cdot 0.5}{x}}}{\left(x \cdot 2\right) \cdot x}\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + 2 \cdot \frac{\color{blue}{0.125}}{x}}{\left(x \cdot 2\right) \cdot x}\right)
\] |
associate-*r/ [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \color{blue}{\frac{2 \cdot 0.125}{x}}}{\left(x \cdot 2\right) \cdot x}\right)
\] |
metadata-eval [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \frac{\color{blue}{0.25}}{x}}{\left(x \cdot 2\right) \cdot x}\right)
\] |
*-commutative [=>]99.6% | \[ \log \left(2 \cdot x - \frac{x + \frac{0.25}{x}}{\color{blue}{x \cdot \left(x \cdot 2\right)}}\right)
\] |
Final simplification99.6%
| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 7360 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 6848 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 6592 |
herbie shell --seed 2023229
(FPCore (x)
:name "Rust f64::acosh"
:precision binary64
:pre (>= x 1.0)
:herbie-target
(log (+ x (* (sqrt (- x 1.0)) (sqrt (+ x 1.0)))))
(log (+ x (sqrt (- (* x x) 1.0)))))