| Alternative 1 | |
|---|---|
| Error | 1.8 |
| Cost | 1220 |
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z)))))
(if (<= x -4.8e+86)
t_0
(if (<= x 2.2e-134) (+ x (* z (- (* x y) x))) t_0))))double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double tmp;
if (x <= -4.8e+86) {
tmp = t_0;
} else if (x <= 2.2e-134) {
tmp = x + (z * ((x * y) - x));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 - ((1.0d0 - y) * z))
if (x <= (-4.8d+86)) then
tmp = t_0
else if (x <= 2.2d-134) then
tmp = x + (z * ((x * y) - x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double tmp;
if (x <= -4.8e+86) {
tmp = t_0;
} else if (x <= 2.2e-134) {
tmp = x + (z * ((x * y) - x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) tmp = 0 if x <= -4.8e+86: tmp = t_0 elif x <= 2.2e-134: tmp = x + (z * ((x * y) - x)) else: tmp = t_0 return tmp
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) tmp = 0.0 if (x <= -4.8e+86) tmp = t_0; elseif (x <= 2.2e-134) tmp = Float64(x + Float64(z * Float64(Float64(x * y) - x))); else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); tmp = 0.0; if (x <= -4.8e+86) tmp = t_0; elseif (x <= 2.2e-134) tmp = x + (z * ((x * y) - x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.8e+86], t$95$0, If[LessEqual[x, 2.2e-134], N[(x + N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-134}:\\
\;\;\;\;x + z \cdot \left(x \cdot y - x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Results
| Original | 3.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.7 |
if x < -4.8000000000000001e86 or 2.2e-134 < x Initial program 1.0
if -4.8000000000000001e86 < x < 2.2e-134Initial program 5.4
Simplified0.4
[Start]5.4 | \[ x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-87 [=>]5.4 | \[ \color{blue}{\left(-x\right) \cdot \left(\left(1 - y\right) \cdot z - 1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-45 [=>]5.4 | \[ \left(-x\right) \cdot \color{blue}{\left(\left(1 - y\right) \cdot z + -1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-37 [=>]5.4 | \[ \color{blue}{\left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right) + \left(-x\right) \cdot -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]5.4 | \[ \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right) + \color{blue}{\left(-\left(-x\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]5.4 | \[ \color{blue}{\left(-\left(-x\right)\right) + \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-97 [=>]5.4 | \[ \color{blue}{\left(0 - \left(-x\right)\right)} + \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-97 [=>]5.4 | \[ \left(0 - \color{blue}{\left(0 - x\right)}\right) + \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-36 [=>]5.4 | \[ \color{blue}{\left(x - \left(0 - 0\right)\right)} + \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right)
\] |
metadata-eval [=>]5.4 | \[ \left(x - \color{blue}{0}\right) + \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-81 [=>]5.4 | \[ \color{blue}{x} + \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]5.4 | \[ x + \color{blue}{\left(-x\right) \cdot \left(\left(1 - y\right) \cdot z\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]5.4 | \[ x + \left(-x\right) \cdot \color{blue}{\left(z \cdot \left(1 - y\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]0.4 | \[ x + \color{blue}{z \cdot \left(\left(-x\right) \cdot \left(1 - y\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-87 [<=]0.4 | \[ x + z \cdot \color{blue}{\left(x \cdot \left(y - 1\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-13 [=>]0.4 | \[ x + z \cdot \color{blue}{\left(y \cdot x - x \cdot 1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]0.4 | \[ x + z \cdot \left(\color{blue}{x \cdot y} - x \cdot 1\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]0.4 | \[ x + z \cdot \left(x \cdot y - \color{blue}{x}\right)
\] |
Final simplification0.7
| Alternative 1 | |
|---|---|
| Error | 1.8 |
| Cost | 1220 |
| Alternative 2 | |
|---|---|
| Error | 13.5 |
| Cost | 848 |
| Alternative 3 | |
|---|---|
| Error | 19.8 |
| Cost | 716 |
| Alternative 4 | |
|---|---|
| Error | 19.9 |
| Cost | 716 |
| Alternative 5 | |
|---|---|
| Error | 13.5 |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Error | 10.2 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 2.3 |
| Cost | 712 |
| Alternative 8 | |
|---|---|
| Error | 1.0 |
| Cost | 712 |
| Alternative 9 | |
|---|---|
| Error | 19.5 |
| Cost | 520 |
| Alternative 10 | |
|---|---|
| Error | 33.8 |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))