
(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) 1e+256) (* x (- 1.0 (* y z))) (/ (* z x) (/ -1.0 y))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= 1e+256) {
tmp = x * (1.0 - (y * z));
} else {
tmp = (z * x) / (-1.0 / y);
}
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 * z) <= 1d+256) then
tmp = x * (1.0d0 - (y * z))
else
tmp = (z * x) / ((-1.0d0) / y)
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 * z) <= 1e+256) {
tmp = x * (1.0 - (y * z));
} else {
tmp = (z * x) / (-1.0 / y);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= 1e+256: tmp = x * (1.0 - (y * z)) else: tmp = (z * x) / (-1.0 / y) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= 1e+256) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = Float64(Float64(z * x) / Float64(-1.0 / y)); 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) <= 1e+256)
tmp = x * (1.0 - (y * z));
else
tmp = (z * x) / (-1.0 / y);
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], 1e+256], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * x), $MachinePrecision] / N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq 10^{+256}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot x}{\frac{-1}{y}}\\
\end{array}
\end{array}
if (*.f64 y z) < 1e256Initial program 99.5%
if 1e256 < (*.f64 y z) Initial program 62.3%
Applied egg-rr0.6%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
neg-sub0N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
flip--N/A
Applied egg-rr62.3%
Taylor expanded in y around inf
/-lowering-/.f64N/A
*-lowering-*.f6462.3%
Simplified62.3%
associate-/r*N/A
associate-/r/N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
clear-numN/A
metadata-evalN/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
clear-numN/A
metadata-evalN/A
distribute-frac-neg2N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
inv-powN/A
pow-flipN/A
/-lowering-/.f64N/A
pow-flipN/A
metadata-evalN/A
inv-powN/A
metadata-evalN/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
metadata-evalN/A
frac-2negN/A
metadata-evalN/A
remove-double-divN/A
remove-double-neg99.7%
Applied egg-rr99.7%
Final simplification99.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (let* ((t_0 (* y (- 0.0 (* z x))))) (if (<= z -1.56e-77) t_0 (if (<= z 1.3e+43) x t_0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = y * (0.0 - (z * x));
double tmp;
if (z <= -1.56e-77) {
tmp = t_0;
} else if (z <= 1.3e+43) {
tmp = x;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = y * (0.0d0 - (z * x))
if (z <= (-1.56d-77)) then
tmp = t_0
else if (z <= 1.3d+43) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = y * (0.0 - (z * x));
double tmp;
if (z <= -1.56e-77) {
tmp = t_0;
} else if (z <= 1.3e+43) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = y * (0.0 - (z * x)) tmp = 0 if z <= -1.56e-77: tmp = t_0 elif z <= 1.3e+43: tmp = x else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(y * Float64(0.0 - Float64(z * x))) tmp = 0.0 if (z <= -1.56e-77) tmp = t_0; elseif (z <= 1.3e+43) tmp = x; else tmp = t_0; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = y * (0.0 - (z * x));
tmp = 0.0;
if (z <= -1.56e-77)
tmp = t_0;
elseif (z <= 1.3e+43)
tmp = x;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(0.0 - N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.56e-77], t$95$0, If[LessEqual[z, 1.3e+43], x, t$95$0]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(0 - z \cdot x\right)\\
\mathbf{if}\;z \leq -1.56 \cdot 10^{-77}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+43}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.5600000000000001e-77 or 1.3000000000000001e43 < z Initial program 93.7%
Applied egg-rr52.8%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
neg-sub0N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
flip--N/A
Applied egg-rr93.6%
Taylor expanded in y around inf
/-lowering-/.f64N/A
*-lowering-*.f6467.3%
Simplified67.3%
frac-2negN/A
distribute-frac-negN/A
neg-lowering-neg.f64N/A
distribute-frac-neg2N/A
neg-mul-1N/A
clear-numN/A
div-invN/A
associate-/r*N/A
associate-/l/N/A
associate-/r/N/A
frac-2negN/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
inv-powN/A
pow-flipN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
pow-flipN/A
metadata-evalN/A
inv-powN/A
metadata-evalN/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
metadata-evalN/A
frac-2negN/A
Applied egg-rr71.4%
if -1.5600000000000001e-77 < z < 1.3000000000000001e43Initial program 99.9%
Taylor expanded in y around 0
Simplified80.8%
Final simplification75.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) 1e+237) (* x (- 1.0 (* y z))) (* y (- 0.0 (* z x)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= 1e+237) {
tmp = x * (1.0 - (y * z));
} else {
tmp = y * (0.0 - (z * 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 * z) <= 1d+237) then
tmp = x * (1.0d0 - (y * z))
else
tmp = y * (0.0d0 - (z * 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 * z) <= 1e+237) {
tmp = x * (1.0 - (y * z));
} else {
tmp = y * (0.0 - (z * x));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= 1e+237: tmp = x * (1.0 - (y * z)) else: tmp = y * (0.0 - (z * x)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= 1e+237) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = Float64(y * Float64(0.0 - Float64(z * 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) <= 1e+237)
tmp = x * (1.0 - (y * z));
else
tmp = y * (0.0 - (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], 1e+237], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(0.0 - N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq 10^{+237}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(0 - z \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 y z) < 9.9999999999999994e236Initial program 99.5%
if 9.9999999999999994e236 < (*.f64 y z) Initial program 71.0%
Applied egg-rr12.4%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
neg-sub0N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
flip--N/A
Applied egg-rr71.0%
Taylor expanded in y around inf
/-lowering-/.f64N/A
*-lowering-*.f6471.0%
Simplified71.0%
frac-2negN/A
distribute-frac-negN/A
neg-lowering-neg.f64N/A
distribute-frac-neg2N/A
neg-mul-1N/A
clear-numN/A
div-invN/A
associate-/r*N/A
associate-/l/N/A
associate-/r/N/A
frac-2negN/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
inv-powN/A
pow-flipN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
pow-flipN/A
metadata-evalN/A
inv-powN/A
metadata-evalN/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
metadata-evalN/A
frac-2negN/A
Applied egg-rr99.7%
Final simplification99.5%
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}
Initial program 96.6%
Taylor expanded in y around 0
Simplified53.3%
herbie shell --seed 2024158
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))