
(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}
(FPCore (x y z) :precision binary64 (if (or (<= (* y z) -2e+252) (not (<= (* y z) 1e+191))) (- (* z (* y x))) (- x (* (* y z) x))))
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+252) || !((y * z) <= 1e+191)) {
tmp = -(z * (y * x));
} else {
tmp = x - ((y * z) * 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 * z) <= (-2d+252)) .or. (.not. ((y * z) <= 1d+191))) then
tmp = -(z * (y * x))
else
tmp = x - ((y * z) * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+252) || !((y * z) <= 1e+191)) {
tmp = -(z * (y * x));
} else {
tmp = x - ((y * z) * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((y * z) <= -2e+252) or not ((y * z) <= 1e+191): tmp = -(z * (y * x)) else: tmp = x - ((y * z) * x) return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -2e+252) || !(Float64(y * z) <= 1e+191)) tmp = Float64(-Float64(z * Float64(y * 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) <= -2e+252) || ~(((y * z) <= 1e+191))) tmp = -(z * (y * x)); else tmp = x - ((y * z) * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -2e+252], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1e+191]], $MachinePrecision]], (-N[(z * N[(y * 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 -2 \cdot 10^{+252} \lor \neg \left(y \cdot z \leq 10^{+191}\right):\\
\;\;\;\;-z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\
\end{array}
\end{array}
if (*.f64 y z) < -2.0000000000000002e252 or 1.00000000000000007e191 < (*.f64 y z) Initial program 74.7%
Taylor expanded in y around inf 74.7%
mul-1-neg74.7%
associate-*r*100.0%
Simplified100.0%
if -2.0000000000000002e252 < (*.f64 y z) < 1.00000000000000007e191Initial program 99.9%
flip--94.9%
associate-*r/92.7%
metadata-eval92.7%
pow292.7%
+-commutative92.7%
fma-def92.7%
Applied egg-rr92.7%
associate-/l*94.8%
Simplified94.8%
Taylor expanded in y around 0 99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*94.6%
Simplified94.6%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= (* y z) -2e+252) (not (<= (* y z) 1e+191))) (- (* z (* y x))) (* x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+252) || !((y * z) <= 1e+191)) {
tmp = -(z * (y * x));
} else {
tmp = x * (1.0 - (y * 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 (((y * z) <= (-2d+252)) .or. (.not. ((y * z) <= 1d+191))) then
tmp = -(z * (y * x))
else
tmp = x * (1.0d0 - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+252) || !((y * z) <= 1e+191)) {
tmp = -(z * (y * x));
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((y * z) <= -2e+252) or not ((y * z) <= 1e+191): tmp = -(z * (y * x)) else: tmp = x * (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -2e+252) || !(Float64(y * z) <= 1e+191)) tmp = Float64(-Float64(z * Float64(y * 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) <= -2e+252) || ~(((y * z) <= 1e+191))) tmp = -(z * (y * x)); else tmp = x * (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -2e+252], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1e+191]], $MachinePrecision]], (-N[(z * N[(y * 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 -2 \cdot 10^{+252} \lor \neg \left(y \cdot z \leq 10^{+191}\right):\\
\;\;\;\;-z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -2.0000000000000002e252 or 1.00000000000000007e191 < (*.f64 y z) Initial program 74.7%
Taylor expanded in y around inf 74.7%
mul-1-neg74.7%
associate-*r*100.0%
Simplified100.0%
if -2.0000000000000002e252 < (*.f64 y z) < 1.00000000000000007e191Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.3e-80) (not (<= z 1.55e+77))) (- (* z (* y x))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.3e-80) || !(z <= 1.55e+77)) {
tmp = -(z * (y * 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 ((z <= (-5.3d-80)) .or. (.not. (z <= 1.55d+77))) then
tmp = -(z * (y * x))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.3e-80) || !(z <= 1.55e+77)) {
tmp = -(z * (y * x));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.3e-80) or not (z <= 1.55e+77): tmp = -(z * (y * x)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.3e-80) || !(z <= 1.55e+77)) tmp = Float64(-Float64(z * Float64(y * x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.3e-80) || ~((z <= 1.55e+77))) tmp = -(z * (y * x)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.3e-80], N[Not[LessEqual[z, 1.55e+77]], $MachinePrecision]], (-N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.3 \cdot 10^{-80} \lor \neg \left(z \leq 1.55 \cdot 10^{+77}\right):\\
\;\;\;\;-z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.30000000000000026e-80 or 1.54999999999999999e77 < z Initial program 91.0%
Taylor expanded in y around inf 62.0%
mul-1-neg62.0%
associate-*r*68.1%
Simplified68.1%
if -5.30000000000000026e-80 < z < 1.54999999999999999e77Initial program 100.0%
Taylor expanded in y around 0 80.0%
Final simplification74.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.3e-80) (not (<= z 2.1e+78))) (* y (* z (- x))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.3e-80) || !(z <= 2.1e+78)) {
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 ((z <= (-5.3d-80)) .or. (.not. (z <= 2.1d+78))) 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 ((z <= -5.3e-80) || !(z <= 2.1e+78)) {
tmp = y * (z * -x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.3e-80) or not (z <= 2.1e+78): tmp = y * (z * -x) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.3e-80) || !(z <= 2.1e+78)) 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 ((z <= -5.3e-80) || ~((z <= 2.1e+78))) tmp = y * (z * -x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.3e-80], N[Not[LessEqual[z, 2.1e+78]], $MachinePrecision]], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.3 \cdot 10^{-80} \lor \neg \left(z \leq 2.1 \cdot 10^{+78}\right):\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.30000000000000026e-80 or 2.1000000000000001e78 < z Initial program 91.0%
Taylor expanded in y around inf 62.0%
mul-1-neg62.0%
associate-*r*68.1%
distribute-rgt-neg-in68.1%
*-commutative68.1%
associate-*r*67.6%
distribute-rgt-neg-out67.6%
Simplified67.6%
if -5.30000000000000026e-80 < z < 2.1000000000000001e78Initial program 100.0%
Taylor expanded in y around 0 80.0%
Final simplification73.8%
(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.4%
Taylor expanded in y around 0 54.5%
Final simplification54.5%
herbie shell --seed 2023322
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))