
(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 6 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 (or (<= (* y z) -2e+259) (not (<= (* y z) 5e+53))) (* y (* z (- x))) (- x (* (* y z) x))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+259) || !((y * z) <= 5e+53)) {
tmp = y * (z * -x);
} 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) <= (-2d+259)) .or. (.not. ((y * z) <= 5d+53))) then
tmp = y * (z * -x)
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) <= -2e+259) || !((y * z) <= 5e+53)) {
tmp = y * (z * -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) <= -2e+259) or not ((y * z) <= 5e+53): tmp = y * (z * -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) <= -2e+259) || !(Float64(y * z) <= 5e+53)) tmp = Float64(y * Float64(z * Float64(-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) <= -2e+259) || ~(((y * z) <= 5e+53)))
tmp = y * (z * -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[Or[LessEqual[N[(y * z), $MachinePrecision], -2e+259], N[Not[LessEqual[N[(y * z), $MachinePrecision], 5e+53]], $MachinePrecision]], N[(y * N[(z * (-x)), $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 -2 \cdot 10^{+259} \lor \neg \left(y \cdot z \leq 5 \cdot 10^{+53}\right):\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\
\end{array}
\end{array}
if (*.f64 y z) < -2e259 or 5.0000000000000004e53 < (*.f64 y z) Initial program 86.1%
Taylor expanded in y around inf 86.1%
Taylor expanded in y around inf 86.1%
associate-*r*86.1%
mul-1-neg86.1%
Simplified86.1%
Taylor expanded in x around 0 86.1%
associate-*r*98.5%
associate-*r*98.5%
mul-1-neg98.5%
*-commutative98.5%
distribute-rgt-neg-in98.5%
associate-*r*98.6%
Simplified98.6%
if -2e259 < (*.f64 y z) < 5.0000000000000004e53Initial program 99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-rgt-neg-in99.9%
Applied egg-rr99.9%
Final simplification99.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= (* y z) -2e+259) (not (<= (* y z) 5e+53))) (* y (* z (- x))) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+259) || !((y * z) <= 5e+53)) {
tmp = y * (z * -x);
} 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) <= (-2d+259)) .or. (.not. ((y * z) <= 5d+53))) then
tmp = y * (z * -x)
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) <= -2e+259) || !((y * z) <= 5e+53)) {
tmp = y * (z * -x);
} 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) <= -2e+259) or not ((y * z) <= 5e+53): tmp = y * (z * -x) 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) <= -2e+259) || !(Float64(y * z) <= 5e+53)) tmp = Float64(y * Float64(z * Float64(-x))); 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) <= -2e+259) || ~(((y * z) <= 5e+53)))
tmp = y * (z * -x);
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[Or[LessEqual[N[(y * z), $MachinePrecision], -2e+259], N[Not[LessEqual[N[(y * z), $MachinePrecision], 5e+53]], $MachinePrecision]], N[(y * N[(z * (-x)), $MachinePrecision]), $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 -2 \cdot 10^{+259} \lor \neg \left(y \cdot z \leq 5 \cdot 10^{+53}\right):\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -2e259 or 5.0000000000000004e53 < (*.f64 y z) Initial program 86.1%
Taylor expanded in y around inf 86.1%
Taylor expanded in y around inf 86.1%
associate-*r*86.1%
mul-1-neg86.1%
Simplified86.1%
Taylor expanded in x around 0 86.1%
associate-*r*98.5%
associate-*r*98.5%
mul-1-neg98.5%
*-commutative98.5%
distribute-rgt-neg-in98.5%
associate-*r*98.6%
Simplified98.6%
if -2e259 < (*.f64 y z) < 5.0000000000000004e53Initial program 99.9%
Final simplification99.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= z -1.6e-104) (not (<= z 1.42e+104))) (* (* y z) (- x)) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.6e-104) || !(z <= 1.42e+104)) {
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 ((z <= (-1.6d-104)) .or. (.not. (z <= 1.42d+104))) 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 ((z <= -1.6e-104) || !(z <= 1.42e+104)) {
tmp = (y * z) * -x;
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (z <= -1.6e-104) or not (z <= 1.42e+104): 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 ((z <= -1.6e-104) || !(z <= 1.42e+104)) 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 ((z <= -1.6e-104) || ~((z <= 1.42e+104)))
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[z, -1.6e-104], N[Not[LessEqual[z, 1.42e+104]], $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}\;z \leq -1.6 \cdot 10^{-104} \lor \neg \left(z \leq 1.42 \cdot 10^{+104}\right):\\
\;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.59999999999999994e-104 or 1.42e104 < z Initial program 92.1%
Taylor expanded in y around inf 69.6%
mul-1-neg69.6%
distribute-rgt-neg-in69.6%
distribute-rgt-neg-out69.6%
Simplified69.6%
if -1.59999999999999994e-104 < z < 1.42e104Initial program 99.9%
Taylor expanded in y around 0 77.7%
Final simplification73.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= z -1.6e-104) (not (<= z 6.5e+84))) (* y (* z (- x))) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.6e-104) || !(z <= 6.5e+84)) {
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 ((z <= (-1.6d-104)) .or. (.not. (z <= 6.5d+84))) 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 ((z <= -1.6e-104) || !(z <= 6.5e+84)) {
tmp = y * (z * -x);
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (z <= -1.6e-104) or not (z <= 6.5e+84): 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 ((z <= -1.6e-104) || !(z <= 6.5e+84)) tmp = Float64(y * Float64(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 ((z <= -1.6e-104) || ~((z <= 6.5e+84)))
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[z, -1.6e-104], N[Not[LessEqual[z, 6.5e+84]], $MachinePrecision]], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.6 \cdot 10^{-104} \lor \neg \left(z \leq 6.5 \cdot 10^{+84}\right):\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.59999999999999994e-104 or 6.50000000000000027e84 < z Initial program 92.2%
Taylor expanded in y around inf 92.1%
Taylor expanded in y around inf 68.7%
associate-*r*68.7%
mul-1-neg68.7%
Simplified68.7%
Taylor expanded in x around 0 68.7%
associate-*r*71.5%
associate-*r*71.5%
mul-1-neg71.5%
*-commutative71.5%
distribute-rgt-neg-in71.5%
associate-*r*73.2%
Simplified73.2%
if -1.59999999999999994e-104 < z < 6.50000000000000027e84Initial program 99.9%
Taylor expanded in y around 0 77.3%
Final simplification75.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 6.3e+137) x (/ (* z x) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 6.3e+137) {
tmp = x;
} else {
tmp = (z * x) / 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 (z <= 6.3d+137) then
tmp = x
else
tmp = (z * x) / 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 (z <= 6.3e+137) {
tmp = x;
} else {
tmp = (z * x) / z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if z <= 6.3e+137: tmp = x else: tmp = (z * x) / z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= 6.3e+137) tmp = x; else tmp = Float64(Float64(z * x) / z); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= 6.3e+137)
tmp = x;
else
tmp = (z * x) / 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[z, 6.3e+137], x, N[(N[(z * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 6.3 \cdot 10^{+137}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot x}{z}\\
\end{array}
\end{array}
if z < 6.29999999999999971e137Initial program 97.7%
Taylor expanded in y around 0 57.5%
if 6.29999999999999971e137 < z Initial program 85.8%
Taylor expanded in z around inf 90.6%
Taylor expanded in y around 0 4.8%
*-commutative4.8%
associate-*l/11.8%
Applied egg-rr11.8%
Final simplification50.2%
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 95.8%
Taylor expanded in y around 0 49.4%
Final simplification49.4%
herbie shell --seed 2024077
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))