
(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}
(FPCore (x y z) :precision binary64 (if (<= (* y z) (- INFINITY)) (* y (* z (- x))) (- x (* (* y z) x))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = y * (z * -x);
} else {
tmp = x - ((y * z) * x);
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -Double.POSITIVE_INFINITY) {
tmp = y * (z * -x);
} else {
tmp = x - ((y * z) * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: tmp = y * (z * -x) else: tmp = x - ((y * z) * x) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= Float64(-Inf)) tmp = Float64(y * Float64(z * Float64(-x))); else tmp = Float64(x - Float64(Float64(y * z) * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -Inf) tmp = y * (z * -x); else tmp = x - ((y * z) * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;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) < -inf.0Initial program 55.8%
Taylor expanded in y around inf 55.8%
mul-1-neg55.8%
associate-*r*99.8%
distribute-rgt-neg-in99.8%
*-commutative99.8%
associate-*l*99.9%
Simplified99.9%
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%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.8e+53) (not (<= y 4.3e-146))) (* y (* z (- x))) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.8e+53) || !(y <= 4.3e-146)) {
tmp = y * (z * -x);
} else {
tmp = x;
}
return tmp;
}
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 <= (-8.8d+53)) .or. (.not. (y <= 4.3d-146))) then
tmp = y * (z * -x)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8.8e+53) || !(y <= 4.3e-146)) {
tmp = y * (z * -x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.8e+53) or not (y <= 4.3e-146): tmp = y * (z * -x) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.8e+53) || !(y <= 4.3e-146)) tmp = Float64(y * Float64(z * Float64(-x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.8e+53) || ~((y <= 4.3e-146))) tmp = y * (z * -x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.8e+53], N[Not[LessEqual[y, 4.3e-146]], $MachinePrecision]], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{+53} \lor \neg \left(y \leq 4.3 \cdot 10^{-146}\right):\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -8.79999999999999994e53 or 4.2999999999999999e-146 < y Initial program 92.0%
Taylor expanded in y around inf 62.8%
mul-1-neg62.8%
associate-*r*64.9%
distribute-rgt-neg-in64.9%
*-commutative64.9%
associate-*l*67.6%
Simplified67.6%
if -8.79999999999999994e53 < y < 4.2999999999999999e-146Initial program 99.9%
Taylor expanded in y around 0 76.4%
Final simplification71.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -7e+89) (not (<= y 5.8e-152))) (* (* y z) (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7e+89) || !(y <= 5.8e-152)) {
tmp = (y * z) * -x;
} else {
tmp = x;
}
return tmp;
}
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 <= (-7d+89)) .or. (.not. (y <= 5.8d-152))) then
tmp = (y * z) * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7e+89) || !(y <= 5.8e-152)) {
tmp = (y * z) * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7e+89) or not (y <= 5.8e-152): tmp = (y * z) * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7e+89) || !(y <= 5.8e-152)) tmp = Float64(Float64(y * z) * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7e+89) || ~((y <= 5.8e-152))) tmp = (y * z) * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7e+89], N[Not[LessEqual[y, 5.8e-152]], $MachinePrecision]], N[(N[(y * z), $MachinePrecision] * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+89} \lor \neg \left(y \leq 5.8 \cdot 10^{-152}\right):\\
\;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -7.0000000000000001e89 or 5.8000000000000003e-152 < y Initial program 92.4%
Taylor expanded in y around inf 65.2%
mul-1-neg65.2%
distribute-rgt-neg-in65.2%
distribute-rgt-neg-out65.2%
Simplified65.2%
if -7.0000000000000001e89 < y < 5.8000000000000003e-152Initial program 99.1%
Taylor expanded in y around 0 77.2%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (if (<= (* y z) (- INFINITY)) (* y (* z (- x))) (* x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = y * (z * -x);
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -Double.POSITIVE_INFINITY) {
tmp = y * (z * -x);
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: tmp = y * (z * -x) else: tmp = x * (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= Float64(-Inf)) tmp = Float64(y * Float64(z * Float64(-x))); else tmp = Float64(x * Float64(1.0 - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -Inf) tmp = y * (z * -x); else tmp = x * (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;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) < -inf.0Initial program 55.8%
Taylor expanded in y around inf 55.8%
mul-1-neg55.8%
associate-*r*99.8%
distribute-rgt-neg-in99.8%
*-commutative99.8%
associate-*l*99.9%
Simplified99.9%
if -inf.0 < (*.f64 y z) Initial program 98.3%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= z 4.6e+193) x (/ (* z x) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= 4.6e+193) {
tmp = x;
} else {
tmp = (z * x) / z;
}
return tmp;
}
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 <= 4.6d+193) then
tmp = x
else
tmp = (z * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 4.6e+193) {
tmp = x;
} else {
tmp = (z * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 4.6e+193: tmp = x else: tmp = (z * x) / z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 4.6e+193) tmp = x; else tmp = Float64(Float64(z * x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 4.6e+193) tmp = x; else tmp = (z * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 4.6e+193], x, N[(N[(z * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.6 \cdot 10^{+193}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot x}{z}\\
\end{array}
\end{array}
if z < 4.60000000000000026e193Initial program 97.0%
Taylor expanded in y around 0 56.8%
if 4.60000000000000026e193 < z Initial program 84.8%
Taylor expanded in z around inf 78.5%
Taylor expanded in y around 0 2.9%
associate-*r/10.7%
Applied egg-rr10.7%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
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
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 95.5%
Taylor expanded in y around 0 50.5%
herbie shell --seed 2024110
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))