| Alternative 1 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 7232 |
\[\sqrt{x \cdot 9} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) + -1\right)
\]

(FPCore (x y) :precision binary64 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
(FPCore (x y) :precision binary64 (* (sqrt (* x 9.0)) (+ (+ y (/ 1.0 (* x 9.0))) -1.0)))
double code(double x, double y) {
return (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
double code(double x, double y) {
return sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 * sqrt(x)) * ((y + (1.0d0 / (x * 9.0d0))) - 1.0d0)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt((x * 9.0d0)) * ((y + (1.0d0 / (x * 9.0d0))) + (-1.0d0))
end function
public static double code(double x, double y) {
return (3.0 * Math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
public static double code(double x, double y) {
return Math.sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0);
}
def code(x, y): return (3.0 * math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0)
def code(x, y): return math.sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0)
function code(x, y) return Float64(Float64(3.0 * sqrt(x)) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) - 1.0)) end
function code(x, y) return Float64(sqrt(Float64(x * 9.0)) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) + -1.0)) end
function tmp = code(x, y) tmp = (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0); end
function tmp = code(x, y) tmp = sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0); end
code[x_, y_] := N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\sqrt{x \cdot 9} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) + -1\right)
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 99.4% |
|---|---|
| Target | 99.4% |
| Herbie | 99.4% |
Initial program 99.4%
Applied egg-rr99.6%
[Start]99.4% | \[ \left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\] |
|---|---|
*-commutative [=>]99.4% | \[ \color{blue}{\left(\sqrt{x} \cdot 3\right)} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\] |
metadata-eval [<=]99.4% | \[ \left(\sqrt{x} \cdot \color{blue}{\sqrt{9}}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\] |
sqrt-prod [<=]99.6% | \[ \color{blue}{\sqrt{x \cdot 9}} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\] |
pow1/2 [=>]99.6% | \[ \color{blue}{{\left(x \cdot 9\right)}^{0.5}} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\] |
Simplified99.6%
[Start]99.6% | \[ {\left(x \cdot 9\right)}^{0.5} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\] |
|---|---|
unpow1/2 [=>]99.6% | \[ \color{blue}{\sqrt{x \cdot 9}} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\] |
Final simplification99.6%
| Alternative 1 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 7232 |
| Alternative 2 | |
|---|---|
| Accuracy | 61.9% |
| Cost | 7380 |
| Alternative 3 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 7113 |
| Alternative 4 | |
|---|---|
| Accuracy | 86.3% |
| Cost | 7108 |
| Alternative 5 | |
|---|---|
| Accuracy | 86.3% |
| Cost | 7108 |
| Alternative 6 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 7104 |
| Alternative 7 | |
|---|---|
| Accuracy | 99.3% |
| Cost | 7104 |
| Alternative 8 | |
|---|---|
| Accuracy | 61.9% |
| Cost | 6985 |
| Alternative 9 | |
|---|---|
| Accuracy | 61.9% |
| Cost | 6984 |
| Alternative 10 | |
|---|---|
| Accuracy | 86.3% |
| Cost | 6980 |
| Alternative 11 | |
|---|---|
| Accuracy | 3.3% |
| Cost | 6592 |
| Alternative 12 | |
|---|---|
| Accuracy | 26.5% |
| Cost | 6592 |
herbie shell --seed 2023165
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(* 3.0 (+ (* y (sqrt x)) (* (- (/ 1.0 (* x 9.0)) 1.0) (sqrt x))))
(* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))