
(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 (- x (* x (* y z))))
double code(double x, double y, double z) {
return x - (x * (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 - (x * (y * z))
end function
public static double code(double x, double y, double z) {
return x - (x * (y * z));
}
def code(x, y, z): return x - (x * (y * z))
function code(x, y, z) return Float64(x - Float64(x * Float64(y * z))) end
function tmp = code(x, y, z) tmp = x - (x * (y * z)); end
code[x_, y_, z_] := N[(x - N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - x \cdot \left(y \cdot z\right)
\end{array}
Initial program 98.1%
Taylor expanded in y around 0 98.1%
mul-1-neg98.1%
associate-*r*94.4%
Simplified94.4%
unsub-neg94.4%
associate-*l*98.1%
Applied egg-rr98.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.1e+67) (not (<= y 1.8e-121))) (* z (* x (- y))) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.1e+67) || !(y <= 1.8e-121)) {
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 ((y <= (-4.1d+67)) .or. (.not. (y <= 1.8d-121))) 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 ((y <= -4.1e+67) || !(y <= 1.8e-121)) {
tmp = z * (x * -y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.1e+67) or not (y <= 1.8e-121): tmp = z * (x * -y) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.1e+67) || !(y <= 1.8e-121)) 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 ((y <= -4.1e+67) || ~((y <= 1.8e-121))) tmp = z * (x * -y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.1e+67], N[Not[LessEqual[y, 1.8e-121]], $MachinePrecision]], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{+67} \lor \neg \left(y \leq 1.8 \cdot 10^{-121}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -4.09999999999999979e67 or 1.79999999999999992e-121 < y Initial program 96.7%
Taylor expanded in y around inf 64.9%
mul-1-neg64.9%
associate-*r*64.2%
Simplified64.2%
if -4.09999999999999979e67 < y < 1.79999999999999992e-121Initial program 99.9%
Taylor expanded in y around 0 81.2%
Final simplification71.7%
(FPCore (x y z) :precision binary64 (if (<= z -4.6e-81) (* y (* x (- z))) (if (<= z 2.2e+63) x (* x (* z (- y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.6e-81) {
tmp = y * (x * -z);
} else if (z <= 2.2e+63) {
tmp = x;
} else {
tmp = x * (z * -y);
}
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-81)) then
tmp = y * (x * -z)
else if (z <= 2.2d+63) then
tmp = x
else
tmp = x * (z * -y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.6e-81) {
tmp = y * (x * -z);
} else if (z <= 2.2e+63) {
tmp = x;
} else {
tmp = x * (z * -y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.6e-81: tmp = y * (x * -z) elif z <= 2.2e+63: tmp = x else: tmp = x * (z * -y) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.6e-81) tmp = Float64(y * Float64(x * Float64(-z))); elseif (z <= 2.2e+63) tmp = x; else tmp = Float64(x * Float64(z * Float64(-y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.6e-81) tmp = y * (x * -z); elseif (z <= 2.2e+63) tmp = x; else tmp = x * (z * -y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.6e-81], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.2e+63], x, N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{-81}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{+63}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if z < -4.59999999999999982e-81Initial program 94.2%
Taylor expanded in y around inf 58.6%
mul-1-neg58.6%
associate-*r*60.0%
distribute-rgt-neg-in60.0%
*-commutative60.0%
associate-*l*62.0%
Simplified62.0%
if -4.59999999999999982e-81 < z < 2.1999999999999999e63Initial program 100.0%
Taylor expanded in y around 0 75.4%
if 2.1999999999999999e63 < z Initial program 99.9%
Taylor expanded in y around 0 99.9%
mul-1-neg99.9%
associate-*r*95.2%
Simplified95.2%
Taylor expanded in y around inf 80.7%
neg-mul-180.7%
distribute-rgt-neg-in80.7%
distribute-lft-neg-in80.7%
Simplified80.7%
Final simplification72.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.9e+66) (* z (* x (- y))) (if (<= y 1.8e-121) x (* x (* z (- y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+66) {
tmp = z * (x * -y);
} else if (y <= 1.8e-121) {
tmp = x;
} else {
tmp = x * (z * -y);
}
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 <= (-1.9d+66)) then
tmp = z * (x * -y)
else if (y <= 1.8d-121) then
tmp = x
else
tmp = x * (z * -y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+66) {
tmp = z * (x * -y);
} else if (y <= 1.8e-121) {
tmp = x;
} else {
tmp = x * (z * -y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.9e+66: tmp = z * (x * -y) elif y <= 1.8e-121: tmp = x else: tmp = x * (z * -y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.9e+66) tmp = Float64(z * Float64(x * Float64(-y))); elseif (y <= 1.8e-121) tmp = x; else tmp = Float64(x * Float64(z * Float64(-y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.9e+66) tmp = z * (x * -y); elseif (y <= 1.8e-121) tmp = x; else tmp = x * (z * -y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.9e+66], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e-121], x, N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+66}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-121}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < -1.9000000000000001e66Initial program 94.7%
Taylor expanded in y around inf 74.1%
mul-1-neg74.1%
associate-*r*75.8%
Simplified75.8%
if -1.9000000000000001e66 < y < 1.79999999999999992e-121Initial program 99.9%
Taylor expanded in y around 0 81.2%
if 1.79999999999999992e-121 < y Initial program 97.9%
Taylor expanded in y around 0 97.9%
mul-1-neg97.9%
associate-*r*94.6%
Simplified94.6%
Taylor expanded in y around inf 59.2%
neg-mul-159.2%
distribute-rgt-neg-in59.2%
distribute-lft-neg-in59.2%
Simplified59.2%
Final simplification72.5%
(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 98.1%
(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 98.1%
Taylor expanded in y around 0 55.0%
herbie shell --seed 2024100
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))