
(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 7 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)) (- x (* z (* y x))) (- 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 = x - (z * (y * x));
} else {
tmp = x - ((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 = x - (z * (y * x));
} else {
tmp = x - ((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 = x - (z * (y * x)) else: tmp = x - ((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(x - Float64(z * Float64(y * x))); else tmp = Float64(x - Float64(Float64(y * 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) <= -Inf)
tmp = x - (z * (y * x));
else
tmp = x - ((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[(x - N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;x - z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\
\end{array}
\end{array}
if (*.f64 y z) < -inf.0Initial program 64.1%
sub-neg64.1%
distribute-rgt-in64.1%
*-un-lft-identity64.1%
distribute-rgt-neg-in64.1%
Applied egg-rr64.1%
*-commutative64.1%
distribute-lft-neg-out64.1%
*-commutative64.1%
add-sqr-sqrt31.1%
sqrt-unprod31.2%
sqr-neg31.2%
sqrt-unprod0.0%
add-sqr-sqrt0.1%
cancel-sign-sub-inv0.1%
*-commutative0.1%
associate-*l*0.1%
add-sqr-sqrt0.1%
sqrt-unprod31.2%
sqr-neg31.2%
sqrt-unprod38.3%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
if -inf.0 < (*.f64 y z) Initial program 98.3%
sub-neg98.3%
distribute-rgt-in98.3%
*-un-lft-identity98.3%
distribute-rgt-neg-in98.3%
Applied egg-rr98.3%
*-commutative98.3%
distribute-lft-neg-out98.3%
*-commutative98.3%
add-sqr-sqrt49.3%
sqrt-unprod68.6%
sqr-neg68.6%
sqrt-unprod27.7%
add-sqr-sqrt55.6%
cancel-sign-sub-inv55.6%
*-commutative55.6%
associate-*l*51.8%
add-sqr-sqrt26.7%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-unprod45.0%
add-sqr-sqrt91.3%
Applied egg-rr91.3%
Taylor expanded in z around 0 98.3%
Final simplification98.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= y -9.5e+137) (not (<= y 7.2e-171))) (* (* z x) (- y)) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.5e+137) || !(y <= 7.2e-171)) {
tmp = (z * x) * -y;
} 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 <= (-9.5d+137)) .or. (.not. (y <= 7.2d-171))) then
tmp = (z * x) * -y
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 <= -9.5e+137) || !(y <= 7.2e-171)) {
tmp = (z * x) * -y;
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y <= -9.5e+137) or not (y <= 7.2e-171): tmp = (z * x) * -y else: tmp = x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((y <= -9.5e+137) || !(y <= 7.2e-171)) tmp = Float64(Float64(z * x) * Float64(-y)); 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 <= -9.5e+137) || ~((y <= 7.2e-171)))
tmp = (z * x) * -y;
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, -9.5e+137], N[Not[LessEqual[y, 7.2e-171]], $MachinePrecision]], N[(N[(z * x), $MachinePrecision] * (-y)), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+137} \lor \neg \left(y \leq 7.2 \cdot 10^{-171}\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -9.50000000000000031e137 or 7.20000000000000006e-171 < y Initial program 94.8%
Taylor expanded in y around inf 63.2%
mul-1-neg63.2%
*-commutative63.2%
associate-*r*65.6%
distribute-rgt-neg-in65.6%
Simplified65.6%
if -9.50000000000000031e137 < y < 7.20000000000000006e-171Initial program 98.4%
Taylor expanded in y around 0 75.8%
Final simplification70.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= y -1e+138) (not (<= y 7.2e-171))) (* (* y z) (- x)) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+138) || !(y <= 7.2e-171)) {
tmp = (y * z) * -x;
} 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 <= (-1d+138)) .or. (.not. (y <= 7.2d-171))) then
tmp = (y * z) * -x
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 <= -1e+138) || !(y <= 7.2e-171)) {
tmp = (y * z) * -x;
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y <= -1e+138) or not (y <= 7.2e-171): tmp = (y * z) * -x else: tmp = x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((y <= -1e+138) || !(y <= 7.2e-171)) tmp = Float64(Float64(y * z) * Float64(-x)); 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 <= -1e+138) || ~((y <= 7.2e-171)))
tmp = (y * z) * -x;
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, -1e+138], N[Not[LessEqual[y, 7.2e-171]], $MachinePrecision]], N[(N[(y * z), $MachinePrecision] * (-x)), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+138} \lor \neg \left(y \leq 7.2 \cdot 10^{-171}\right):\\
\;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1e138 or 7.20000000000000006e-171 < y Initial program 94.8%
Taylor expanded in y around inf 63.2%
mul-1-neg63.2%
distribute-rgt-neg-out63.2%
Simplified63.2%
if -1e138 < y < 7.20000000000000006e-171Initial program 98.4%
Taylor expanded in y around 0 75.8%
Final simplification69.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) -5e+276) (* (* z x) (- y)) (- x (* (* y z) x))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -5e+276) {
tmp = (z * x) * -y;
} else {
tmp = x - ((y * 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) <= (-5d+276)) then
tmp = (z * x) * -y
else
tmp = x - ((y * 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) <= -5e+276) {
tmp = (z * x) * -y;
} else {
tmp = x - ((y * z) * x);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= -5e+276: tmp = (z * x) * -y else: tmp = x - ((y * z) * x) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -5e+276) tmp = Float64(Float64(z * x) * Float64(-y)); else tmp = Float64(x - Float64(Float64(y * 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) <= -5e+276)
tmp = (z * x) * -y;
else
tmp = x - ((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], -5e+276], N[(N[(z * x), $MachinePrecision] * (-y)), $MachinePrecision], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+276}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\
\end{array}
\end{array}
if (*.f64 y z) < -5.00000000000000001e276Initial program 73.9%
Taylor expanded in y around inf 73.9%
mul-1-neg73.9%
*-commutative73.9%
associate-*r*99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
if -5.00000000000000001e276 < (*.f64 y z) Initial program 98.3%
sub-neg98.3%
distribute-rgt-in98.3%
*-un-lft-identity98.3%
distribute-rgt-neg-in98.3%
Applied egg-rr98.3%
*-commutative98.3%
distribute-lft-neg-out98.3%
*-commutative98.3%
add-sqr-sqrt49.1%
sqrt-unprod69.6%
sqr-neg69.6%
sqrt-unprod28.3%
add-sqr-sqrt56.7%
cancel-sign-sub-inv56.7%
*-commutative56.7%
associate-*l*52.8%
add-sqr-sqrt27.3%
sqrt-unprod65.9%
sqr-neg65.9%
sqrt-unprod44.7%
add-sqr-sqrt91.2%
Applied egg-rr91.2%
Taylor expanded in z around 0 98.3%
Final simplification98.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) -5e+276) (* (* z x) (- y)) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -5e+276) {
tmp = (z * x) * -y;
} else {
tmp = x * (1.0 - (y * z));
}
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) <= (-5d+276)) then
tmp = (z * x) * -y
else
tmp = x * (1.0d0 - (y * z))
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) <= -5e+276) {
tmp = (z * x) * -y;
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= -5e+276: tmp = (z * x) * -y else: tmp = x * (1.0 - (y * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -5e+276) tmp = Float64(Float64(z * x) * Float64(-y)); else tmp = Float64(x * Float64(1.0 - Float64(y * z))); 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) <= -5e+276)
tmp = (z * x) * -y;
else
tmp = x * (1.0 - (y * z));
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], -5e+276], N[(N[(z * x), $MachinePrecision] * (-y)), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+276}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -5.00000000000000001e276Initial program 73.9%
Taylor expanded in y around inf 73.9%
mul-1-neg73.9%
*-commutative73.9%
associate-*r*99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
if -5.00000000000000001e276 < (*.f64 y z) Initial program 98.3%
Final simplification98.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -7.2e+158) (/ (* y x) y) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+158) {
tmp = (y * x) / y;
} 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 <= (-7.2d+158)) then
tmp = (y * x) / y
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 <= -7.2e+158) {
tmp = (y * x) / y;
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -7.2e+158: tmp = (y * x) / y else: tmp = x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -7.2e+158) tmp = Float64(Float64(y * x) / y); 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 <= -7.2e+158)
tmp = (y * x) / y;
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[LessEqual[y, -7.2e+158], N[(N[(y * x), $MachinePrecision] / y), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+158}:\\
\;\;\;\;\frac{y \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -7.19999999999999976e158Initial program 93.9%
Taylor expanded in y around inf 92.9%
Taylor expanded in z around 0 10.6%
associate-*r/29.2%
*-commutative29.2%
Applied egg-rr29.2%
if -7.19999999999999976e158 < y Initial program 97.0%
Taylor expanded in y around 0 60.2%
Final simplification56.3%
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 54.2%
herbie shell --seed 2024139
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))