
(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) -5e+96) (* y (- (* x z))) (if (<= (* y z) 2e+187) (* x (- 1.0 (* y z))) (* z (* x (- y))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -5e+96) {
tmp = y * -(x * z);
} else if ((y * z) <= 2e+187) {
tmp = x * (1.0 - (y * z));
} 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 * z) <= (-5d+96)) then
tmp = y * -(x * z)
else if ((y * z) <= 2d+187) then
tmp = x * (1.0d0 - (y * z))
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 * z) <= -5e+96) {
tmp = y * -(x * z);
} else if ((y * z) <= 2e+187) {
tmp = x * (1.0 - (y * z));
} else {
tmp = z * (x * -y);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= -5e+96: tmp = y * -(x * z) elif (y * z) <= 2e+187: tmp = x * (1.0 - (y * z)) else: tmp = z * (x * -y) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -5e+96) tmp = Float64(y * Float64(-Float64(x * z))); elseif (Float64(y * z) <= 2e+187) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = Float64(z * Float64(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 * z) <= -5e+96)
tmp = y * -(x * z);
elseif ((y * z) <= 2e+187)
tmp = x * (1.0 - (y * z));
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[N[(y * z), $MachinePrecision], -5e+96], N[(y * (-N[(x * z), $MachinePrecision])), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 2e+187], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * (-y)), $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^{+96}:\\
\;\;\;\;y \cdot \left(-x \cdot z\right)\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+187}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -5.0000000000000004e96Initial program 90.1%
Taylor expanded in y around inf 90.1%
mul-1-neg90.1%
*-commutative90.1%
associate-*r*96.0%
distribute-rgt-neg-in96.0%
Simplified96.0%
if -5.0000000000000004e96 < (*.f64 y z) < 1.99999999999999981e187Initial program 99.9%
if 1.99999999999999981e187 < (*.f64 y z) Initial program 71.4%
Taylor expanded in z around inf 99.9%
Taylor expanded in y around inf 99.9%
mul-1-neg99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Final simplification99.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= y -5.2e+26) (not (<= y 2.2e-110))) (* x (* y (- z))) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.2e+26) || !(y <= 2.2e-110)) {
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 <= (-5.2d+26)) .or. (.not. (y <= 2.2d-110))) 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 <= -5.2e+26) || !(y <= 2.2e-110)) {
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 <= -5.2e+26) or not (y <= 2.2e-110): 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 <= -5.2e+26) || !(y <= 2.2e-110)) 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 <= -5.2e+26) || ~((y <= 2.2e-110)))
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, -5.2e+26], N[Not[LessEqual[y, 2.2e-110]], $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 -5.2 \cdot 10^{+26} \lor \neg \left(y \leq 2.2 \cdot 10^{-110}\right):\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -5.20000000000000004e26 or 2.1999999999999999e-110 < y Initial program 92.2%
Taylor expanded in y around inf 65.6%
mul-1-neg65.6%
distribute-rgt-neg-out65.6%
Simplified65.6%
if -5.20000000000000004e26 < y < 2.1999999999999999e-110Initial program 99.9%
Taylor expanded in y around 0 79.6%
Final simplification71.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -1.08e+29) (* y (- (* x z))) (if (<= y 2.2e-110) x (* z (* x (- y))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -1.08e+29) {
tmp = y * -(x * z);
} else if (y <= 2.2e-110) {
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.08d+29)) then
tmp = y * -(x * z)
else if (y <= 2.2d-110) 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.08e+29) {
tmp = y * -(x * z);
} else if (y <= 2.2e-110) {
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.08e+29: tmp = y * -(x * z) elif y <= 2.2e-110: 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.08e+29) tmp = Float64(y * Float64(-Float64(x * z))); elseif (y <= 2.2e-110) tmp = x; else tmp = Float64(z * Float64(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.08e+29)
tmp = y * -(x * z);
elseif (y <= 2.2e-110)
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.08e+29], N[(y * (-N[(x * z), $MachinePrecision])), $MachinePrecision], If[LessEqual[y, 2.2e-110], x, N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.08 \cdot 10^{+29}:\\
\;\;\;\;y \cdot \left(-x \cdot z\right)\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-110}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < -1.0800000000000001e29Initial program 89.9%
Taylor expanded in y around inf 73.7%
mul-1-neg73.7%
*-commutative73.7%
associate-*r*83.6%
distribute-rgt-neg-in83.6%
Simplified83.6%
if -1.0800000000000001e29 < y < 2.1999999999999999e-110Initial program 99.9%
Taylor expanded in y around 0 79.6%
if 2.1999999999999999e-110 < y Initial program 93.7%
Taylor expanded in z around inf 86.5%
Taylor expanded in y around inf 63.6%
mul-1-neg63.6%
*-commutative63.6%
distribute-rgt-neg-in63.6%
Simplified63.6%
Final simplification74.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -2.35e+27) (* x (* y (- z))) (if (<= y 2.2e-110) x (* z (* x (- y))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -2.35e+27) {
tmp = x * (y * -z);
} else if (y <= 2.2e-110) {
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 <= (-2.35d+27)) then
tmp = x * (y * -z)
else if (y <= 2.2d-110) 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 <= -2.35e+27) {
tmp = x * (y * -z);
} else if (y <= 2.2e-110) {
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 <= -2.35e+27: tmp = x * (y * -z) elif y <= 2.2e-110: 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 <= -2.35e+27) tmp = Float64(x * Float64(y * Float64(-z))); elseif (y <= 2.2e-110) tmp = x; else tmp = Float64(z * Float64(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 <= -2.35e+27)
tmp = x * (y * -z);
elseif (y <= 2.2e-110)
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, -2.35e+27], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e-110], x, N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.35 \cdot 10^{+27}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-110}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < -2.34999999999999988e27Initial program 89.9%
Taylor expanded in y around inf 73.7%
mul-1-neg73.7%
distribute-rgt-neg-out73.7%
Simplified73.7%
if -2.34999999999999988e27 < y < 2.1999999999999999e-110Initial program 99.9%
Taylor expanded in y around 0 79.6%
if 2.1999999999999999e-110 < y Initial program 93.7%
Taylor expanded in z around inf 86.5%
Taylor expanded in y around inf 63.6%
mul-1-neg63.6%
*-commutative63.6%
distribute-rgt-neg-in63.6%
Simplified63.6%
Final simplification72.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= x 195000000000.0) (* y (- (/ x y) (* x z))) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (x <= 195000000000.0) {
tmp = y * ((x / y) - (x * z));
} 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 (x <= 195000000000.0d0) then
tmp = y * ((x / y) - (x * z))
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 (x <= 195000000000.0) {
tmp = y * ((x / y) - (x * z));
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if x <= 195000000000.0: tmp = y * ((x / y) - (x * z)) 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 (x <= 195000000000.0) tmp = Float64(y * Float64(Float64(x / y) - Float64(x * z))); 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 (x <= 195000000000.0)
tmp = y * ((x / y) - (x * z));
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[x, 195000000000.0], N[(y * N[(N[(x / y), $MachinePrecision] - N[(x * z), $MachinePrecision]), $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}\;x \leq 195000000000:\\
\;\;\;\;y \cdot \left(\frac{x}{y} - x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if x < 1.95e11Initial program 93.7%
sub-neg93.7%
distribute-rgt-in93.7%
*-un-lft-identity93.7%
distribute-rgt-neg-in93.7%
Applied egg-rr93.7%
Taylor expanded in y around inf 89.6%
+-commutative89.6%
mul-1-neg89.6%
*-commutative89.6%
unsub-neg89.6%
*-commutative89.6%
Simplified89.6%
if 1.95e11 < x Initial program 99.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 1e+24) x (/ (* x z) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (z <= 1e+24) {
tmp = x;
} else {
tmp = (x * z) / 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 <= 1d+24) then
tmp = x
else
tmp = (x * z) / 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 <= 1e+24) {
tmp = x;
} else {
tmp = (x * z) / z;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if z <= 1e+24: tmp = x else: tmp = (x * z) / z return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (z <= 1e+24) tmp = x; else tmp = Float64(Float64(x * z) / 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 <= 1e+24)
tmp = x;
else
tmp = (x * z) / 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, 1e+24], x, N[(N[(x * z), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+24}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot z}{z}\\
\end{array}
\end{array}
if z < 9.9999999999999998e23Initial program 96.7%
Taylor expanded in y around 0 52.4%
if 9.9999999999999998e23 < z Initial program 89.5%
Taylor expanded in z around inf 89.2%
Taylor expanded in y around 0 27.1%
associate-*r/33.8%
Applied egg-rr33.8%
Final simplification49.1%
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.4%
Taylor expanded in y around 0 48.7%
herbie shell --seed 2024136
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))