
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
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 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
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 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) (- INFINITY)) (* (* y x) (- z)) (if (<= (* y z) 2e+167) (- x (* (* y z) x)) (* y (* z (- x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = (y * x) * -z;
} else if ((y * z) <= 2e+167) {
tmp = x - ((y * z) * x);
} else {
tmp = y * (z * -x);
}
return tmp;
}
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -Double.POSITIVE_INFINITY) {
tmp = (y * x) * -z;
} else if ((y * z) <= 2e+167) {
tmp = x - ((y * z) * x);
} else {
tmp = y * (z * -x);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: tmp = (y * x) * -z elif (y * z) <= 2e+167: tmp = x - ((y * z) * x) else: tmp = y * (z * -x) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= Float64(-Inf)) tmp = Float64(Float64(y * x) * Float64(-z)); elseif (Float64(y * z) <= 2e+167) tmp = Float64(x - Float64(Float64(y * z) * x)); else tmp = Float64(y * Float64(z * Float64(-x))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((y * z) <= -Inf)
tmp = (y * x) * -z;
elseif ((y * z) <= 2e+167)
tmp = x - ((y * z) * x);
else
tmp = y * (z * -x);
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[(N[(y * x), $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 2e+167], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;\left(y \cdot x\right) \cdot \left(-z\right)\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+167}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\end{array}
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) (- INFINITY)) (* (* y x) (- z)) (if (<= (* y z) 2e+167) (* x (- 1.0 (* y z))) (* y (* z (- x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = (y * x) * -z;
} else if ((y * z) <= 2e+167) {
tmp = x * (1.0 - (y * z));
} else {
tmp = y * (z * -x);
}
return tmp;
}
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -Double.POSITIVE_INFINITY) {
tmp = (y * x) * -z;
} else if ((y * z) <= 2e+167) {
tmp = x * (1.0 - (y * z));
} else {
tmp = y * (z * -x);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: tmp = (y * x) * -z elif (y * z) <= 2e+167: tmp = x * (1.0 - (y * z)) else: tmp = y * (z * -x) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= Float64(-Inf)) tmp = Float64(Float64(y * x) * Float64(-z)); elseif (Float64(y * z) <= 2e+167) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = Float64(y * Float64(z * Float64(-x))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((y * z) <= -Inf)
tmp = (y * x) * -z;
elseif ((y * z) <= 2e+167)
tmp = x * (1.0 - (y * z));
else
tmp = y * (z * -x);
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[(N[(y * x), $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 2e+167], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;\left(y \cdot x\right) \cdot \left(-z\right)\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+167}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\end{array}
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= y -1.22e+32) (not (<= y 7e-174))) (* (* y x) (- z)) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.22e+32) || !(y <= 7e-174)) {
tmp = (y * x) * -z;
} else {
tmp = x;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this 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) :: tmp
if ((y <= (-1.22d+32)) .or. (.not. (y <= 7d-174))) then
tmp = (y * x) * -z
else
tmp = x
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.22e+32) || !(y <= 7e-174)) {
tmp = (y * x) * -z;
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y <= -1.22e+32) or not (y <= 7e-174): tmp = (y * x) * -z else: tmp = x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((y <= -1.22e+32) || !(y <= 7e-174)) tmp = Float64(Float64(y * x) * Float64(-z)); else tmp = x; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((y <= -1.22e+32) || ~((y <= 7e-174)))
tmp = (y * x) * -z;
else
tmp = x;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[Or[LessEqual[y, -1.22e+32], N[Not[LessEqual[y, 7e-174]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] * (-z)), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.22 \cdot 10^{+32} \lor \neg \left(y \leq 7 \cdot 10^{-174}\right):\\
\;\;\;\;\left(y \cdot x\right) \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 x)
assert(x < y && y < z);
double code(double x, double y, double z) {
return x;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x
x, y, z = sort([x, y, z]) function code(x, y, z) return x end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := x
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x
\end{array}
herbie shell --seed 2023343
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))