| Alternative 1 | |
|---|---|
| Accuracy | 97.4% |
| Cost | 576 |
\[x + \frac{z - x}{\frac{t}{y}}
\]

(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t) :precision binary64 (+ x (/ (- z x) (/ t y))))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
return x + ((z - x) / (t / y));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * (z - x)) / t)
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((z - x) / (t / y))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
public static double code(double x, double y, double z, double t) {
return x + ((z - x) / (t / y));
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
def code(x, y, z, t): return x + ((z - x) / (t / y))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function code(x, y, z, t) return Float64(x + Float64(Float64(z - x) / Float64(t / y))) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
function tmp = code(x, y, z, t) tmp = x + ((z - x) / (t / y)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(x + N[(N[(z - x), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{y \cdot \left(z - x\right)}{t}
x + \frac{z - x}{\frac{t}{y}}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 92.3% |
|---|---|
| Target | 91.0% |
| Herbie | 97.4% |
Initial program 93.7%
Simplified97.0%
[Start]93.7% | \[ x + \frac{y \cdot \left(z - x\right)}{t}
\] |
|---|---|
associate-*l/ [<=]97.0% | \[ x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)}
\] |
Applied egg-rr97.1%
[Start]97.0% | \[ x + \frac{y}{t} \cdot \left(z - x\right)
\] |
|---|---|
*-commutative [=>]97.0% | \[ x + \color{blue}{\left(z - x\right) \cdot \frac{y}{t}}
\] |
clear-num [=>]96.9% | \[ x + \left(z - x\right) \cdot \color{blue}{\frac{1}{\frac{t}{y}}}
\] |
un-div-inv [=>]97.1% | \[ x + \color{blue}{\frac{z - x}{\frac{t}{y}}}
\] |
Final simplification97.1%
| Alternative 1 | |
|---|---|
| Accuracy | 97.4% |
| Cost | 576 |
| Alternative 2 | |
|---|---|
| Accuracy | 84.3% |
| Cost | 713 |
| Alternative 3 | |
|---|---|
| Accuracy | 50.8% |
| Cost | 649 |
| Alternative 4 | |
|---|---|
| Accuracy | 77.0% |
| Cost | 580 |
| Alternative 5 | |
|---|---|
| Accuracy | 76.9% |
| Cost | 580 |
| Alternative 6 | |
|---|---|
| Accuracy | 97.4% |
| Cost | 576 |
| Alternative 7 | |
|---|---|
| Accuracy | 38.6% |
| Cost | 64 |
herbie shell --seed 2023263
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:herbie-target
(- x (+ (* x (/ y t)) (* (- z) (/ y t))))
(+ x (/ (* y (- z x)) t)))