| Alternative 1 | |
|---|---|
| Error | 30.8 |
| Cost | 1232 |
(FPCore (x y z t) :precision binary64 (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(FPCore (x y z t) :precision binary64 (+ (/ x y) (+ -2.0 (/ (+ 2.0 (/ 2.0 z)) t))))
double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
double code(double x, double y, double z, double t) {
return (x / y) + (-2.0 + ((2.0 + (2.0 / z)) / t));
}
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) + ((2.0d0 + ((z * 2.0d0) * (1.0d0 - t))) / (t * z))
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 / y) + ((-2.0d0) + ((2.0d0 + (2.0d0 / z)) / t))
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
public static double code(double x, double y, double z, double t) {
return (x / y) + (-2.0 + ((2.0 + (2.0 / z)) / t));
}
def code(x, y, z, t): return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z))
def code(x, y, z, t): return (x / y) + (-2.0 + ((2.0 + (2.0 / z)) / t))
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z))) end
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(-2.0 + Float64(Float64(2.0 + Float64(2.0 / z)) / t))) end
function tmp = code(x, y, z, t) tmp = (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z)); end
function tmp = code(x, y, z, t) tmp = (x / y) + (-2.0 + ((2.0 + (2.0 / z)) / t)); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(-2.0 + N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\frac{x}{y} + \left(-2 + \frac{2 + \frac{2}{z}}{t}\right)
Results
| Original | 9.4 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
Initial program 9.4
Simplified0.1
[Start]9.4 | \[ \frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\] |
|---|---|
+-rgt-identity [<=]9.4 | \[ \color{blue}{\left(\frac{x}{y} + 0\right)} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\] |
mul0-lft [<=]9.4 | \[ \left(\frac{x}{y} + \color{blue}{0 \cdot \frac{2}{t \cdot z}}\right) + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\] |
associate-+r+ [<=]9.4 | \[ \color{blue}{\frac{x}{y} + \left(0 \cdot \frac{2}{t \cdot z} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\right)}
\] |
mul0-lft [=>]9.4 | \[ \frac{x}{y} + \left(\color{blue}{0} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\right)
\] |
+-lft-identity [=>]9.4 | \[ \frac{x}{y} + \color{blue}{\frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}}
\] |
sub-neg [=>]9.4 | \[ \frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \color{blue}{\left(1 + \left(-t\right)\right)}}{t \cdot z}
\] |
distribute-rgt-in [=>]9.4 | \[ \frac{x}{y} + \frac{2 + \color{blue}{\left(1 \cdot \left(z \cdot 2\right) + \left(-t\right) \cdot \left(z \cdot 2\right)\right)}}{t \cdot z}
\] |
associate-+r+ [=>]9.4 | \[ \frac{x}{y} + \frac{\color{blue}{\left(2 + 1 \cdot \left(z \cdot 2\right)\right) + \left(-t\right) \cdot \left(z \cdot 2\right)}}{t \cdot z}
\] |
cancel-sign-sub-inv [<=]9.4 | \[ \frac{x}{y} + \frac{\color{blue}{\left(2 + 1 \cdot \left(z \cdot 2\right)\right) - t \cdot \left(z \cdot 2\right)}}{t \cdot z}
\] |
div-sub [=>]9.4 | \[ \frac{x}{y} + \color{blue}{\left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} - \frac{t \cdot \left(z \cdot 2\right)}{t \cdot z}\right)}
\] |
associate-*r* [=>]9.4 | \[ \frac{x}{y} + \left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} - \frac{\color{blue}{\left(t \cdot z\right) \cdot 2}}{t \cdot z}\right)
\] |
associate-*l/ [<=]9.4 | \[ \frac{x}{y} + \left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} - \color{blue}{\frac{t \cdot z}{t \cdot z} \cdot 2}\right)
\] |
*-inverses [=>]0.1 | \[ \frac{x}{y} + \left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} - \color{blue}{1} \cdot 2\right)
\] |
metadata-eval [=>]0.1 | \[ \frac{x}{y} + \left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} - \color{blue}{2}\right)
\] |
sub-neg [=>]0.1 | \[ \frac{x}{y} + \color{blue}{\left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} + \left(-2\right)\right)}
\] |
metadata-eval [=>]0.1 | \[ \frac{x}{y} + \left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} + \color{blue}{-2}\right)
\] |
metadata-eval [<=]0.1 | \[ \frac{x}{y} + \left(\frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z} + \color{blue}{2 \cdot -1}\right)
\] |
+-commutative [<=]0.1 | \[ \frac{x}{y} + \color{blue}{\left(2 \cdot -1 + \frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z}\right)}
\] |
metadata-eval [=>]0.1 | \[ \frac{x}{y} + \left(\color{blue}{-2} + \frac{2 + 1 \cdot \left(z \cdot 2\right)}{t \cdot z}\right)
\] |
associate-*r* [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{2 + \color{blue}{\left(1 \cdot z\right) \cdot 2}}{t \cdot z}\right)
\] |
distribute-rgt1-in [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\color{blue}{\left(1 \cdot z + 1\right) \cdot 2}}{t \cdot z}\right)
\] |
times-frac [=>]9.6 | \[ \frac{x}{y} + \left(-2 + \color{blue}{\frac{1 \cdot z + 1}{t} \cdot \frac{2}{z}}\right)
\] |
*-commutative [<=]9.6 | \[ \frac{x}{y} + \left(-2 + \color{blue}{\frac{2}{z} \cdot \frac{1 \cdot z + 1}{t}}\right)
\] |
associate-*r/ [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \color{blue}{\frac{\frac{2}{z} \cdot \left(1 \cdot z + 1\right)}{t}}\right)
\] |
*-lft-identity [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\frac{2}{z} \cdot \left(\color{blue}{z} + 1\right)}{t}\right)
\] |
distribute-rgt-in [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\color{blue}{z \cdot \frac{2}{z} + 1 \cdot \frac{2}{z}}}{t}\right)
\] |
/-rgt-identity [<=]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\color{blue}{\frac{z}{1}} \cdot \frac{2}{z} + 1 \cdot \frac{2}{z}}{t}\right)
\] |
times-frac [<=]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\color{blue}{\frac{z \cdot 2}{1 \cdot z}} + 1 \cdot \frac{2}{z}}{t}\right)
\] |
*-lft-identity [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\frac{z \cdot 2}{\color{blue}{z}} + 1 \cdot \frac{2}{z}}{t}\right)
\] |
*-commutative [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\frac{\color{blue}{2 \cdot z}}{z} + 1 \cdot \frac{2}{z}}{t}\right)
\] |
associate-/l* [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\color{blue}{\frac{2}{\frac{z}{z}}} + 1 \cdot \frac{2}{z}}{t}\right)
\] |
*-inverses [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\frac{2}{\color{blue}{1}} + 1 \cdot \frac{2}{z}}{t}\right)
\] |
metadata-eval [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{\color{blue}{2} + 1 \cdot \frac{2}{z}}{t}\right)
\] |
*-lft-identity [=>]0.1 | \[ \frac{x}{y} + \left(-2 + \frac{2 + \color{blue}{\frac{2}{z}}}{t}\right)
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 30.8 |
| Cost | 1232 |
| Alternative 2 | |
|---|---|
| Error | 15.9 |
| Cost | 1228 |
| Alternative 3 | |
|---|---|
| Error | 5.0 |
| Cost | 1097 |
| Alternative 4 | |
|---|---|
| Error | 4.9 |
| Cost | 1097 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 969 |
| Alternative 6 | |
|---|---|
| Error | 20.0 |
| Cost | 840 |
| Alternative 7 | |
|---|---|
| Error | 12.6 |
| Cost | 713 |
| Alternative 8 | |
|---|---|
| Error | 20.3 |
| Cost | 585 |
| Alternative 9 | |
|---|---|
| Error | 34.0 |
| Cost | 456 |
| Alternative 10 | |
|---|---|
| Error | 48.1 |
| Cost | 64 |
herbie shell --seed 2022364
(FPCore (x y z t)
:name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
:precision binary64
:herbie-target
(- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y)))
(+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))