
(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)) (- (* z (* y x))) (- x (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = -(z * (y * x));
} else {
tmp = x - (x * (y * z));
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -Double.POSITIVE_INFINITY) {
tmp = -(z * (y * x));
} else {
tmp = x - (x * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: tmp = -(z * (y * x)) else: tmp = x - (x * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= Float64(-Inf)) tmp = Float64(-Float64(z * Float64(y * x))); else tmp = Float64(x - Float64(x * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -Inf) tmp = -(z * (y * x)); else tmp = x - (x * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], (-N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), N[(x - N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;-z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -inf.0Initial program 36.9%
Taylor expanded in y around inf 99.8%
Taylor expanded in z around inf 99.8%
mul-1-neg99.8%
distribute-rgt-neg-out99.8%
associate-*l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
if -inf.0 < (*.f64 y z) Initial program 98.7%
sub-neg98.7%
distribute-rgt-in98.7%
*-un-lft-identity98.7%
distribute-rgt-neg-in98.7%
Applied egg-rr98.7%
add-sqr-sqrt47.7%
sqrt-unprod65.5%
sqr-neg65.5%
sqrt-unprod25.3%
add-sqr-sqrt52.2%
cancel-sign-sub52.2%
distribute-rgt-neg-out52.2%
*-commutative52.2%
*-commutative52.2%
associate-*r*50.6%
distribute-rgt-neg-in50.6%
*-commutative50.6%
distribute-rgt-neg-in50.6%
associate-*r*49.0%
distribute-lft-neg-in49.0%
mul-1-neg49.0%
add-sqr-sqrt29.9%
sqrt-unprod59.0%
mul-1-neg59.0%
mul-1-neg59.0%
sqr-neg59.0%
Applied egg-rr89.0%
Taylor expanded in z around 0 98.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* z (* y x))))) (if (<= z -1.2e-19) t_0 (if (<= z 2.7e+55) x t_0))))
double code(double x, double y, double z) {
double t_0 = -(z * (y * x));
double tmp;
if (z <= -1.2e-19) {
tmp = t_0;
} else if (z <= 2.7e+55) {
tmp = x;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = -(z * (y * x))
if (z <= (-1.2d-19)) then
tmp = t_0
else if (z <= 2.7d+55) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -(z * (y * x));
double tmp;
if (z <= -1.2e-19) {
tmp = t_0;
} else if (z <= 2.7e+55) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -(z * (y * x)) tmp = 0 if z <= -1.2e-19: tmp = t_0 elif z <= 2.7e+55: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-Float64(z * Float64(y * x))) tmp = 0.0 if (z <= -1.2e-19) tmp = t_0; elseif (z <= 2.7e+55) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(z * (y * x)); tmp = 0.0; if (z <= -1.2e-19) tmp = t_0; elseif (z <= 2.7e+55) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[z, -1.2e-19], t$95$0, If[LessEqual[z, 2.7e+55], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -z \cdot \left(y \cdot x\right)\\
\mathbf{if}\;z \leq -1.2 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{+55}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.20000000000000011e-19 or 2.69999999999999977e55 < z Initial program 89.7%
Taylor expanded in y around inf 90.5%
Taylor expanded in z around inf 75.7%
mul-1-neg75.7%
distribute-rgt-neg-out75.7%
associate-*l*70.9%
*-commutative70.9%
Applied egg-rr70.9%
if -1.20000000000000011e-19 < z < 2.69999999999999977e55Initial program 99.9%
Taylor expanded in y around 0 75.7%
(FPCore (x y z) :precision binary64 (if (<= (* y z) (- INFINITY)) (- (* z (* y x))) (* x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = -(z * (y * 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 = -(z * (y * x));
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: 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) <= Float64(-Inf)) 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) <= -Inf) tmp = -(z * (y * 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[(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 -\infty:\\
\;\;\;\;-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) < -inf.0Initial program 36.9%
Taylor expanded in y around inf 99.8%
Taylor expanded in z around inf 99.8%
mul-1-neg99.8%
distribute-rgt-neg-out99.8%
associate-*l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
if -inf.0 < (*.f64 y z) Initial program 98.7%
(FPCore (x y z) :precision binary64 (if (<= y -6.2e+215) (/ (* y x) y) x))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.2e+215) {
tmp = (y * 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 <= (-6.2d+215)) then
tmp = (y * 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 <= -6.2e+215) {
tmp = (y * x) / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.2e+215: tmp = (y * x) / y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.2e+215) tmp = Float64(Float64(y * x) / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.2e+215) tmp = (y * x) / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.2e+215], N[(N[(y * x), $MachinePrecision] / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+215}:\\
\;\;\;\;\frac{y \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -6.1999999999999998e215Initial program 86.2%
Taylor expanded in y around inf 99.4%
Taylor expanded in z around 0 10.0%
associate-*r/23.9%
Applied egg-rr23.9%
if -6.1999999999999998e215 < y Initial program 95.6%
Taylor expanded in y around 0 53.1%
(FPCore (x y z) :precision binary64 (if (<= z 1.6e+185) x (/ (* z x) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.6e+185) {
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 <= 1.6d+185) 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 <= 1.6e+185) {
tmp = x;
} else {
tmp = (z * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.6e+185: tmp = x else: tmp = (z * x) / z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.6e+185) 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 <= 1.6e+185) tmp = x; else tmp = (z * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.6e+185], x, N[(N[(z * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.6 \cdot 10^{+185}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot x}{z}\\
\end{array}
\end{array}
if z < 1.60000000000000003e185Initial program 95.0%
Taylor expanded in y around 0 54.9%
if 1.60000000000000003e185 < z Initial program 96.0%
Taylor expanded in z around inf 69.6%
Taylor expanded in y around 0 4.7%
associate-*r/26.2%
Applied egg-rr26.2%
(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.1%
Taylor expanded in y around 0 50.7%
herbie shell --seed 2024076 -o generate:simplify
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))