
(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 5 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 -1.25e+214) (* z (* y (- x))) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.25e+214) {
tmp = z * (y * -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 <= (-1.25d+214)) then
tmp = z * (y * -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 <= -1.25e+214) {
tmp = z * (y * -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 <= -1.25e+214: tmp = z * (y * -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 (y <= -1.25e+214) tmp = Float64(z * Float64(y * 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 <= -1.25e+214)
tmp = z * (y * -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[LessEqual[y, -1.25e+214], N[(z * N[(y * (-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 \leq -1.25 \cdot 10^{+214}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if y < -1.24999999999999988e214Initial program 81.3%
Taylor expanded in z around inf 93.1%
Taylor expanded in y around inf 99.8%
neg-mul-199.8%
distribute-lft-neg-in99.8%
Simplified99.8%
if -1.24999999999999988e214 < y Initial program 97.2%
Final simplification97.3%
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.95e+61) (not (<= y 3.4e-154))) (* x (* y (- z))) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.95e+61) || !(y <= 3.4e-154)) {
tmp = x * (y * -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.95d+61)) .or. (.not. (y <= 3.4d-154))) then
tmp = x * (y * -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.95e+61) || !(y <= 3.4e-154)) {
tmp = x * (y * -z);
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y <= -1.95e+61) or not (y <= 3.4e-154): tmp = x * (y * -z) else: tmp = x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((y <= -1.95e+61) || !(y <= 3.4e-154)) tmp = Float64(x * Float64(y * 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.95e+61) || ~((y <= 3.4e-154)))
tmp = x * (y * -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.95e+61], N[Not[LessEqual[y, 3.4e-154]], $MachinePrecision]], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+61} \lor \neg \left(y \leq 3.4 \cdot 10^{-154}\right):\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.94999999999999994e61 or 3.3999999999999998e-154 < y Initial program 94.1%
Taylor expanded in y around inf 61.8%
mul-1-neg61.8%
distribute-rgt-neg-out61.8%
Simplified61.8%
if -1.94999999999999994e61 < y < 3.3999999999999998e-154Initial program 99.1%
Taylor expanded in y around 0 71.2%
Final simplification65.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -1.8e+61) (* z (* y (- x))) (if (<= y 3.4e-154) x (* x (* y (- z))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+61) {
tmp = z * (y * -x);
} else if (y <= 3.4e-154) {
tmp = x;
} else {
tmp = x * (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 <= (-1.8d+61)) then
tmp = z * (y * -x)
else if (y <= 3.4d-154) then
tmp = x
else
tmp = x * (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 <= -1.8e+61) {
tmp = z * (y * -x);
} else if (y <= 3.4e-154) {
tmp = x;
} else {
tmp = x * (y * -z);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -1.8e+61: tmp = z * (y * -x) elif y <= 3.4e-154: tmp = x else: tmp = x * (y * -z) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.8e+61) tmp = Float64(z * Float64(y * Float64(-x))); elseif (y <= 3.4e-154) tmp = x; else tmp = Float64(x * Float64(y * Float64(-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 <= -1.8e+61)
tmp = z * (y * -x);
elseif (y <= 3.4e-154)
tmp = x;
else
tmp = x * (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[y, -1.8e+61], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e-154], x, N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+61}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-154}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if y < -1.80000000000000005e61Initial program 84.5%
Taylor expanded in z around inf 93.3%
Taylor expanded in y around inf 81.1%
neg-mul-181.1%
distribute-lft-neg-in81.1%
Simplified81.1%
if -1.80000000000000005e61 < y < 3.3999999999999998e-154Initial program 99.1%
Taylor expanded in y around 0 71.2%
if 3.3999999999999998e-154 < y Initial program 98.9%
Taylor expanded in y around inf 59.7%
mul-1-neg59.7%
distribute-rgt-neg-out59.7%
Simplified59.7%
Final simplification68.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 1.85e+96) x (/ (* z x) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.85e+96) {
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 <= 1.85d+96) 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 <= 1.85e+96) {
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 <= 1.85e+96: 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 <= 1.85e+96) 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 <= 1.85e+96)
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, 1.85e+96], 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 1.85 \cdot 10^{+96}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot x}{z}\\
\end{array}
\end{array}
if z < 1.84999999999999996e96Initial program 96.1%
Taylor expanded in y around 0 55.2%
if 1.84999999999999996e96 < z Initial program 97.2%
Taylor expanded in z around inf 88.0%
Taylor expanded in y around 0 15.7%
associate-*r/32.5%
*-commutative32.5%
Applied egg-rr32.5%
Final simplification52.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.2%
Taylor expanded in y around 0 50.9%
herbie shell --seed 2024185
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))