
(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 7 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 (* (* y z) x))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = z * (y * -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 = z * (y * -x);
} else {
tmp = x - ((y * z) * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: tmp = z * (y * -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(z * Float64(y * 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 = z * (y * -x); else tmp = x - ((y * z) * x); 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[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;z \cdot \left(y \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 58.3%
Taylor expanded in z around inf 99.8%
Taylor expanded in y around inf 99.8%
neg-mul-199.8%
distribute-lft-neg-in99.8%
Simplified99.8%
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%
associate-*l*94.5%
add-sqr-sqrt44.3%
sqrt-unprod66.0%
sqr-neg66.0%
sqrt-unprod26.3%
add-sqr-sqrt50.7%
cancel-sign-sub-inv50.7%
associate-*l*52.3%
distribute-rgt-neg-out52.3%
distribute-lft-neg-in52.3%
associate-*r*50.7%
add-sqr-sqrt26.3%
sqrt-unprod66.0%
sqr-neg66.0%
sqrt-unprod44.3%
add-sqr-sqrt94.5%
*-commutative94.5%
*-commutative94.5%
associate-*l*98.3%
*-commutative98.3%
Applied egg-rr98.3%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -5e-141) (not (<= z 1.45e+84))) (* z (* y (- x))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5e-141) || !(z <= 1.45e+84)) {
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 <= (-5d-141)) .or. (.not. (z <= 1.45d+84))) 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 <= -5e-141) || !(z <= 1.45e+84)) {
tmp = z * (y * -x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5e-141) or not (z <= 1.45e+84): tmp = z * (y * -x) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5e-141) || !(z <= 1.45e+84)) tmp = Float64(z * Float64(y * Float64(-x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5e-141) || ~((z <= 1.45e+84))) tmp = z * (y * -x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5e-141], N[Not[LessEqual[z, 1.45e+84]], $MachinePrecision]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-141} \lor \neg \left(z \leq 1.45 \cdot 10^{+84}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.9999999999999999e-141 or 1.44999999999999994e84 < z Initial program 92.3%
Taylor expanded in z around inf 94.3%
Taylor expanded in y around inf 68.2%
neg-mul-168.2%
distribute-lft-neg-in68.2%
Simplified68.2%
if -4.9999999999999999e-141 < z < 1.44999999999999994e84Initial program 99.9%
Taylor expanded in y around 0 73.3%
Final simplification70.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -9.8e+75) (not (<= y 6.8e-118))) (* (* y z) (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.8e+75) || !(y <= 6.8e-118)) {
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 <= (-9.8d+75)) .or. (.not. (y <= 6.8d-118))) 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 <= -9.8e+75) || !(y <= 6.8e-118)) {
tmp = (y * z) * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9.8e+75) or not (y <= 6.8e-118): tmp = (y * z) * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9.8e+75) || !(y <= 6.8e-118)) 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 <= -9.8e+75) || ~((y <= 6.8e-118))) tmp = (y * z) * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.8e+75], N[Not[LessEqual[y, 6.8e-118]], $MachinePrecision]], N[(N[(y * z), $MachinePrecision] * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{+75} \lor \neg \left(y \leq 6.8 \cdot 10^{-118}\right):\\
\;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -9.8000000000000002e75 or 6.79999999999999981e-118 < y Initial program 91.6%
Taylor expanded in y around inf 66.0%
mul-1-neg66.0%
distribute-rgt-neg-out66.0%
Simplified66.0%
if -9.8000000000000002e75 < y < 6.79999999999999981e-118Initial program 99.9%
Taylor expanded in y around 0 72.3%
Final simplification69.2%
(FPCore (x y z) :precision binary64 (if (<= y -5.3e+97) (* z (* y (- x))) (if (<= y 2.05e-119) x (* y (* z (- x))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.3e+97) {
tmp = z * (y * -x);
} else if (y <= 2.05e-119) {
tmp = x;
} else {
tmp = 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 <= (-5.3d+97)) then
tmp = z * (y * -x)
else if (y <= 2.05d-119) then
tmp = x
else
tmp = y * (z * -x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.3e+97) {
tmp = z * (y * -x);
} else if (y <= 2.05e-119) {
tmp = x;
} else {
tmp = y * (z * -x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.3e+97: tmp = z * (y * -x) elif y <= 2.05e-119: tmp = x else: tmp = y * (z * -x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.3e+97) tmp = Float64(z * Float64(y * Float64(-x))); elseif (y <= 2.05e-119) tmp = x; else tmp = Float64(y * Float64(z * Float64(-x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.3e+97) tmp = z * (y * -x); elseif (y <= 2.05e-119) tmp = x; else tmp = y * (z * -x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.3e+97], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.05e-119], x, N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{+97}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{-119}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\end{array}
\end{array}
if y < -5.3000000000000003e97Initial program 85.5%
Taylor expanded in z around inf 85.0%
Taylor expanded in y around inf 82.9%
neg-mul-182.9%
distribute-lft-neg-in82.9%
Simplified82.9%
if -5.3000000000000003e97 < y < 2.0500000000000001e-119Initial program 99.9%
Taylor expanded in y around 0 71.0%
if 2.0500000000000001e-119 < y Initial program 94.1%
Taylor expanded in y around inf 61.0%
mul-1-neg61.0%
*-commutative61.0%
associate-*r*63.3%
distribute-rgt-neg-in63.3%
Simplified63.3%
Final simplification70.3%
(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(z * Float64(y * 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 = 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 \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 58.3%
Taylor expanded in z around inf 99.8%
Taylor expanded in y around inf 99.8%
neg-mul-199.8%
distribute-lft-neg-in99.8%
Simplified99.8%
if -inf.0 < (*.f64 y z) Initial program 98.3%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= x 2.5e+163) x (/ (* z x) z)))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.5e+163) {
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 (x <= 2.5d+163) 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 (x <= 2.5e+163) {
tmp = x;
} else {
tmp = (z * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2.5e+163: tmp = x else: tmp = (z * x) / z return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2.5e+163) tmp = x; else tmp = Float64(Float64(z * x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2.5e+163) tmp = x; else tmp = (z * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2.5e+163], x, N[(N[(z * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5 \cdot 10^{+163}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot x}{z}\\
\end{array}
\end{array}
if x < 2.5e163Initial program 95.1%
Taylor expanded in y around 0 52.0%
if 2.5e163 < x Initial program 99.9%
Taylor expanded in z around inf 80.0%
Taylor expanded in y around 0 31.7%
*-commutative31.7%
associate-*l/41.2%
Applied egg-rr41.2%
Final simplification50.4%
(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.8%
Taylor expanded in y around 0 50.4%
herbie shell --seed 2024184
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))