
(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 (<= z 1.7e+185) (* x (- 1.0 (* z y))) (* z (- (/ x z) (* x y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.7e+185) {
tmp = x * (1.0 - (z * y));
} else {
tmp = z * ((x / z) - (x * 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 (z <= 1.7d+185) then
tmp = x * (1.0d0 - (z * y))
else
tmp = z * ((x / z) - (x * 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 (z <= 1.7e+185) {
tmp = x * (1.0 - (z * y));
} else {
tmp = z * ((x / z) - (x * y));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if z <= 1.7e+185: tmp = x * (1.0 - (z * y)) else: tmp = z * ((x / z) - (x * y)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= 1.7e+185) tmp = Float64(x * Float64(1.0 - Float64(z * y))); else tmp = Float64(z * Float64(Float64(x / z) - Float64(x * y))); 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.7e+185)
tmp = x * (1.0 - (z * y));
else
tmp = z * ((x / z) - (x * 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[z, 1.7e+185], N[(x * N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(x / z), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.7 \cdot 10^{+185}:\\
\;\;\;\;x \cdot \left(1 - z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\frac{x}{z} - x \cdot y\right)\\
\end{array}
\end{array}
if z < 1.70000000000000009e185Initial program 98.7%
if 1.70000000000000009e185 < z Initial program 83.4%
Taylor expanded in z around inf 99.8%
Final simplification98.8%
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.16e+88) (not (<= y 3.9e-84))) (* x (* z (- y))) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.16e+88) || !(y <= 3.9e-84)) {
tmp = x * (z * -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 <= (-1.16d+88)) .or. (.not. (y <= 3.9d-84))) then
tmp = x * (z * -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 <= -1.16e+88) || !(y <= 3.9e-84)) {
tmp = x * (z * -y);
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y <= -1.16e+88) or not (y <= 3.9e-84): tmp = x * (z * -y) else: tmp = x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((y <= -1.16e+88) || !(y <= 3.9e-84)) tmp = Float64(x * Float64(z * 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 <= -1.16e+88) || ~((y <= 3.9e-84)))
tmp = x * (z * -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, -1.16e+88], N[Not[LessEqual[y, 3.9e-84]], $MachinePrecision]], N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.16 \cdot 10^{+88} \lor \neg \left(y \leq 3.9 \cdot 10^{-84}\right):\\
\;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.1599999999999999e88 or 3.90000000000000023e-84 < y Initial program 95.7%
Taylor expanded in y around inf 68.0%
mul-1-neg68.0%
distribute-rgt-neg-out68.0%
Simplified68.0%
if -1.1599999999999999e88 < y < 3.90000000000000023e-84Initial program 100.0%
Taylor expanded in y around 0 80.9%
Final simplification74.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -1.4e+88) (* x (* z (- y))) (if (<= y 3.9e-84) x (* (* z x) (- y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e+88) {
tmp = x * (z * -y);
} else if (y <= 3.9e-84) {
tmp = x;
} else {
tmp = (z * x) * -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 <= (-1.4d+88)) then
tmp = x * (z * -y)
else if (y <= 3.9d-84) then
tmp = x
else
tmp = (z * x) * -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 <= -1.4e+88) {
tmp = x * (z * -y);
} else if (y <= 3.9e-84) {
tmp = x;
} else {
tmp = (z * x) * -y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -1.4e+88: tmp = x * (z * -y) elif y <= 3.9e-84: tmp = x else: tmp = (z * x) * -y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.4e+88) tmp = Float64(x * Float64(z * Float64(-y))); elseif (y <= 3.9e-84) tmp = x; else tmp = Float64(Float64(z * x) * Float64(-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 <= -1.4e+88)
tmp = x * (z * -y);
elseif (y <= 3.9e-84)
tmp = x;
else
tmp = (z * x) * -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[y, -1.4e+88], N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.9e-84], x, N[(N[(z * x), $MachinePrecision] * (-y)), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+88}:\\
\;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-84}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\
\end{array}
\end{array}
if y < -1.39999999999999994e88Initial program 98.0%
Taylor expanded in y around inf 84.5%
mul-1-neg84.5%
distribute-rgt-neg-out84.5%
Simplified84.5%
if -1.39999999999999994e88 < y < 3.90000000000000023e-84Initial program 100.0%
Taylor expanded in y around 0 80.9%
if 3.90000000000000023e-84 < y Initial program 94.2%
Taylor expanded in y around inf 57.7%
mul-1-neg57.7%
*-commutative57.7%
associate-*r*63.3%
distribute-rgt-neg-in63.3%
Simplified63.3%
Final simplification75.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.16e+88) (* x (* z (- y))) (if (<= y 3.9e-84) x (* z (* y (- x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.16e+88) {
tmp = x * (z * -y);
} else if (y <= 3.9e-84) {
tmp = x;
} else {
tmp = z * (y * -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.16d+88)) then
tmp = x * (z * -y)
else if (y <= 3.9d-84) then
tmp = x
else
tmp = z * (y * -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.16e+88) {
tmp = x * (z * -y);
} else if (y <= 3.9e-84) {
tmp = x;
} else {
tmp = z * (y * -x);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -1.16e+88: tmp = x * (z * -y) elif y <= 3.9e-84: tmp = x else: tmp = z * (y * -x) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -1.16e+88) tmp = Float64(x * Float64(z * Float64(-y))); elseif (y <= 3.9e-84) tmp = x; else tmp = Float64(z * Float64(y * 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 <= -1.16e+88)
tmp = x * (z * -y);
elseif (y <= 3.9e-84)
tmp = x;
else
tmp = z * (y * -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, -1.16e+88], N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.9e-84], x, N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.16 \cdot 10^{+88}:\\
\;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-84}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\end{array}
\end{array}
if y < -1.1599999999999999e88Initial program 98.0%
Taylor expanded in y around inf 84.5%
mul-1-neg84.5%
distribute-rgt-neg-out84.5%
Simplified84.5%
if -1.1599999999999999e88 < y < 3.90000000000000023e-84Initial program 100.0%
Taylor expanded in y around 0 80.9%
if 3.90000000000000023e-84 < y Initial program 94.2%
Taylor expanded in z around inf 87.2%
Taylor expanded in y around inf 60.4%
mul-1-neg60.4%
Applied egg-rr60.4%
Final simplification75.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 6.8e+187) x (/ (* z x) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 6.8e+187) {
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.8d+187) 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.8e+187) {
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.8e+187: 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.8e+187) 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.8e+187)
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.8e+187], 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.8 \cdot 10^{+187}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot x}{z}\\
\end{array}
\end{array}
if z < 6.7999999999999999e187Initial program 98.7%
Taylor expanded in y around 0 56.6%
if 6.7999999999999999e187 < z Initial program 83.4%
Taylor expanded in z around inf 99.8%
Taylor expanded in y around 0 9.0%
associate-*r/32.0%
Applied egg-rr32.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x (- 1.0 (* z y))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * (1.0 - (z * y));
}
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 * (1.0d0 - (z * y))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x * (1.0 - (z * y));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x * (1.0 - (z * y))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * Float64(1.0 - Float64(z * y))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x * (1.0 - (z * y));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot \left(1 - z \cdot y\right)
\end{array}
Initial program 97.7%
Final simplification97.7%
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 97.7%
Taylor expanded in y around 0 53.5%
herbie shell --seed 2024140
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))