| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 448 |
\[x + \frac{x - y}{2}
\]

(FPCore (x y) :precision binary64 (+ x (/ (- x y) 2.0)))
(FPCore (x y) :precision binary64 (+ x (/ (- x y) 2.0)))
double code(double x, double y) {
return x + ((x - y) / 2.0);
}
double code(double x, double y) {
return x + ((x - y) / 2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((x - y) / 2.0d0)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((x - y) / 2.0d0)
end function
public static double code(double x, double y) {
return x + ((x - y) / 2.0);
}
public static double code(double x, double y) {
return x + ((x - y) / 2.0);
}
def code(x, y): return x + ((x - y) / 2.0)
def code(x, y): return x + ((x - y) / 2.0)
function code(x, y) return Float64(x + Float64(Float64(x - y) / 2.0)) end
function code(x, y) return Float64(x + Float64(Float64(x - y) / 2.0)) end
function tmp = code(x, y) tmp = x + ((x - y) / 2.0); end
function tmp = code(x, y) tmp = x + ((x - y) / 2.0); end
code[x_, y_] := N[(x + N[(N[(x - y), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(x + N[(N[(x - y), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
x + \frac{x - y}{2}
x + \frac{x - y}{2}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 99.9% |
|---|---|
| Target | 99.9% |
| Herbie | 99.9% |
Initial program 99.9%
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 448 |
| Alternative 2 | |
|---|---|
| Accuracy | 76.9% |
| Cost | 585 |
| Alternative 3 | |
|---|---|
| Accuracy | 75.1% |
| Cost | 456 |
| Alternative 4 | |
|---|---|
| Accuracy | 50.2% |
| Cost | 324 |
| Alternative 5 | |
|---|---|
| Accuracy | 11.8% |
| Cost | 64 |
herbie shell --seed 2023272
(FPCore (x y)
:name "Graphics.Rendering.Chart.Axis.Types:hBufferRect from Chart-1.5.3"
:precision binary64
:herbie-target
(- (* 1.5 x) (* 0.5 y))
(+ x (/ (- x y) 2.0)))