| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 1216 |
\[\left(\frac{x}{x + y} \cdot \frac{1}{x + y}\right) \cdot \frac{y}{x + \left(y + 1\right)}
\]

(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
(FPCore (x y) :precision binary64 (* (* (/ x (+ x y)) (/ 1.0 (+ x y))) (/ y (+ x (+ y 1.0)))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
double code(double x, double y) {
return ((x / (x + y)) * (1.0 / (x + y))) * (y / (x + (y + 1.0)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / (x + y)) * (1.0d0 / (x + y))) * (y / (x + (y + 1.0d0)))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
public static double code(double x, double y) {
return ((x / (x + y)) * (1.0 / (x + y))) * (y / (x + (y + 1.0)));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
def code(x, y): return ((x / (x + y)) * (1.0 / (x + y))) * (y / (x + (y + 1.0)))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function code(x, y) return Float64(Float64(Float64(x / Float64(x + y)) * Float64(1.0 / Float64(x + y))) * Float64(y / Float64(x + Float64(y + 1.0)))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
function tmp = code(x, y) tmp = ((x / (x + y)) * (1.0 / (x + y))) * (y / (x + (y + 1.0))); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x + N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\left(\frac{x}{x + y} \cdot \frac{1}{x + y}\right) \cdot \frac{y}{x + \left(y + 1\right)}
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 68.7% |
|---|---|
| Target | 99.8% |
| Herbie | 99.7% |
Initial program 70.3%
Simplified90.8%
[Start]70.3% | \[ \frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\] |
|---|---|
times-frac [=>]90.8% | \[ \color{blue}{\frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{y}{\left(x + y\right) + 1}}
\] |
/-rgt-identity [<=]90.8% | \[ \frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \color{blue}{\frac{\frac{y}{\left(x + y\right) + 1}}{1}}
\] |
associate-/l/ [=>]90.8% | \[ \frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \color{blue}{\frac{y}{1 \cdot \left(\left(x + y\right) + 1\right)}}
\] |
*-lft-identity [=>]90.8% | \[ \frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{y}{\color{blue}{\left(x + y\right) + 1}}
\] |
associate-+l+ [=>]90.8% | \[ \frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{y}{\color{blue}{x + \left(y + 1\right)}}
\] |
Applied egg-rr99.8%
[Start]90.8% | \[ \frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{y}{x + \left(y + 1\right)}
\] |
|---|---|
associate-/r* [=>]99.8% | \[ \color{blue}{\frac{\frac{x}{x + y}}{x + y}} \cdot \frac{y}{x + \left(y + 1\right)}
\] |
div-inv [=>]99.8% | \[ \color{blue}{\left(\frac{x}{x + y} \cdot \frac{1}{x + y}\right)} \cdot \frac{y}{x + \left(y + 1\right)}
\] |
+-commutative [=>]99.8% | \[ \left(\frac{x}{\color{blue}{y + x}} \cdot \frac{1}{x + y}\right) \cdot \frac{y}{x + \left(y + 1\right)}
\] |
+-commutative [=>]99.8% | \[ \left(\frac{x}{y + x} \cdot \frac{1}{\color{blue}{y + x}}\right) \cdot \frac{y}{x + \left(y + 1\right)}
\] |
Final simplification99.8%
| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 1216 |
| Alternative 2 | |
|---|---|
| Accuracy | 97.2% |
| Cost | 1352 |
| Alternative 3 | |
|---|---|
| Accuracy | 86.8% |
| Cost | 1224 |
| Alternative 4 | |
|---|---|
| Accuracy | 94.6% |
| Cost | 1092 |
| Alternative 5 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 1088 |
| Alternative 6 | |
|---|---|
| Accuracy | 76.1% |
| Cost | 976 |
| Alternative 7 | |
|---|---|
| Accuracy | 85.7% |
| Cost | 972 |
| Alternative 8 | |
|---|---|
| Accuracy | 85.7% |
| Cost | 972 |
| Alternative 9 | |
|---|---|
| Accuracy | 72.5% |
| Cost | 848 |
| Alternative 10 | |
|---|---|
| Accuracy | 74.6% |
| Cost | 848 |
| Alternative 11 | |
|---|---|
| Accuracy | 76.0% |
| Cost | 848 |
| Alternative 12 | |
|---|---|
| Accuracy | 81.5% |
| Cost | 844 |
| Alternative 13 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 840 |
| Alternative 14 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 840 |
| Alternative 15 | |
|---|---|
| Accuracy | 81.6% |
| Cost | 712 |
| Alternative 16 | |
|---|---|
| Accuracy | 64.5% |
| Cost | 584 |
| Alternative 17 | |
|---|---|
| Accuracy | 28.3% |
| Cost | 324 |
| Alternative 18 | |
|---|---|
| Accuracy | 44.1% |
| Cost | 324 |
| Alternative 19 | |
|---|---|
| Accuracy | 4.3% |
| Cost | 192 |
herbie shell --seed 2023272
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
:herbie-target
(/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x))))
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))