
(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 4 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 (* 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}
Initial program 97.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.8e-74) (not (<= z 1.25e+73))) (* z (* x (- y))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e-74) || !(z <= 1.25e+73)) {
tmp = z * (x * -y);
} 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 <= (-2.8d-74)) .or. (.not. (z <= 1.25d+73))) then
tmp = z * (x * -y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e-74) || !(z <= 1.25e+73)) {
tmp = z * (x * -y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.8e-74) or not (z <= 1.25e+73): tmp = z * (x * -y) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.8e-74) || !(z <= 1.25e+73)) tmp = Float64(z * Float64(x * Float64(-y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.8e-74) || ~((z <= 1.25e+73))) tmp = z * (x * -y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.8e-74], N[Not[LessEqual[z, 1.25e+73]], $MachinePrecision]], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-74} \lor \neg \left(z \leq 1.25 \cdot 10^{+73}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.79999999999999988e-74 or 1.24999999999999994e73 < z Initial program 95.1%
sub-neg95.1%
distribute-rgt-in95.1%
*-un-lft-identity95.1%
distribute-rgt-neg-in95.1%
Applied egg-rr95.1%
add-sqr-sqrt62.4%
sqrt-unprod56.5%
sqr-neg56.5%
sqrt-unprod6.6%
add-sqr-sqrt25.3%
cancel-sign-sub25.3%
distribute-rgt-neg-out25.3%
*-commutative25.3%
associate-*l*25.3%
add-sqr-sqrt18.7%
sqrt-unprod35.2%
sqr-neg35.2%
sqrt-unprod35.4%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 69.5%
mul-1-neg69.5%
*-commutative69.5%
*-commutative69.5%
distribute-rgt-neg-in69.5%
associate-*r*74.1%
Simplified74.1%
if -2.79999999999999988e-74 < z < 1.24999999999999994e73Initial program 99.2%
Taylor expanded in y around 0 72.4%
Final simplification73.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.8e-74) (not (<= z 1.25e+73))) (* x (* y (- z))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e-74) || !(z <= 1.25e+73)) {
tmp = x * (y * -z);
} 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 <= (-2.8d-74)) .or. (.not. (z <= 1.25d+73))) then
tmp = x * (y * -z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e-74) || !(z <= 1.25e+73)) {
tmp = x * (y * -z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.8e-74) or not (z <= 1.25e+73): tmp = x * (y * -z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.8e-74) || !(z <= 1.25e+73)) tmp = Float64(x * Float64(y * Float64(-z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.8e-74) || ~((z <= 1.25e+73))) tmp = x * (y * -z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.8e-74], N[Not[LessEqual[z, 1.25e+73]], $MachinePrecision]], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-74} \lor \neg \left(z \leq 1.25 \cdot 10^{+73}\right):\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.79999999999999988e-74 or 1.24999999999999994e73 < z Initial program 95.1%
Taylor expanded in y around inf 69.5%
mul-1-neg69.5%
distribute-rgt-neg-in69.5%
distribute-rgt-neg-out69.5%
Simplified69.5%
if -2.79999999999999988e-74 < z < 1.24999999999999994e73Initial program 99.2%
Taylor expanded in y around 0 72.4%
Final simplification71.0%
(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 97.3%
Taylor expanded in y around 0 51.4%
herbie shell --seed 2024135
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))