| Alternative 1 | |
|---|---|
| Accuracy | 98.0% |
| Cost | 964 |
\[\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]

(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- 1.0 (* y z))))) (if (<= t_0 (- INFINITY)) (* y (* x (- z))) t_0)))
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
double code(double x, double y, double z) {
double t_0 = x * (1.0 - (y * z));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = y * (x * -z);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - (y * z));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = y * (x * -z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): return x * (1.0 - (y * z))
def code(x, y, z): t_0 = x * (1.0 - (y * z)) tmp = 0 if t_0 <= -math.inf: tmp = y * (x * -z) else: tmp = t_0 return tmp
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(y * z))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(y * Float64(x * Float64(-z))); else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - (y * z)); tmp = 0.0; if (t_0 <= -Inf) tmp = y * (x * -z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision], t$95$0]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
if (*.f64 x (-.f64 1 (*.f64 y z))) < -inf.0Initial program 78.3%
Taylor expanded in y around inf 99.9%
Simplified99.9%
[Start]99.9% | \[ -1 \cdot \left(y \cdot \left(z \cdot x\right)\right)
\] |
|---|---|
mul-1-neg [=>]99.9% | \[ \color{blue}{-y \cdot \left(z \cdot x\right)}
\] |
distribute-rgt-neg-in [=>]99.9% | \[ \color{blue}{y \cdot \left(-z \cdot x\right)}
\] |
distribute-lft-neg-out [<=]99.9% | \[ y \cdot \color{blue}{\left(\left(-z\right) \cdot x\right)}
\] |
*-commutative [=>]99.9% | \[ y \cdot \color{blue}{\left(x \cdot \left(-z\right)\right)}
\] |
if -inf.0 < (*.f64 x (-.f64 1 (*.f64 y z))) Initial program 98.6%
Final simplification98.8%
| Alternative 1 | |
|---|---|
| Accuracy | 98.0% |
| Cost | 964 |
| Alternative 2 | |
|---|---|
| Accuracy | 71.0% |
| Cost | 649 |
| Alternative 3 | |
|---|---|
| Accuracy | 71.9% |
| Cost | 648 |
| Alternative 4 | |
|---|---|
| Accuracy | 50.6% |
| Cost | 64 |
herbie shell --seed 2023271
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))