
(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 (if (<= (* y z) (- INFINITY)) (* (* (- y) x) z) (* x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = (-y * x) * z;
} 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 = (-y * x) * z;
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: tmp = (-y * x) * z 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(Float64(-y) * x) * z); 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 = (-y * x) * z; else tmp = x * (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[(N[((-y) * x), $MachinePrecision] * z), $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:\\
\;\;\;\;\left(\left(-y\right) \cdot x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -inf.0Initial program 58.9%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6458.9
Applied rewrites58.9%
Applied rewrites58.9%
Applied rewrites58.9%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
if -inf.0 < (*.f64 y z) Initial program 98.2%
(FPCore (x y z)
:precision binary64
(if (<= (* y z) (- INFINITY))
(* (* (- y) x) z)
(if (or (<= (* y z) -5.0) (not (<= (* y z) 5e-6)))
(* x (* (- y) z))
(* x 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -((double) INFINITY)) {
tmp = (-y * x) * z;
} else if (((y * z) <= -5.0) || !((y * z) <= 5e-6)) {
tmp = x * (-y * z);
} else {
tmp = x * 1.0;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -Double.POSITIVE_INFINITY) {
tmp = (-y * x) * z;
} else if (((y * z) <= -5.0) || !((y * z) <= 5e-6)) {
tmp = x * (-y * z);
} else {
tmp = x * 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -math.inf: tmp = (-y * x) * z elif ((y * z) <= -5.0) or not ((y * z) <= 5e-6): tmp = x * (-y * z) else: tmp = x * 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= Float64(-Inf)) tmp = Float64(Float64(Float64(-y) * x) * z); elseif ((Float64(y * z) <= -5.0) || !(Float64(y * z) <= 5e-6)) tmp = Float64(x * Float64(Float64(-y) * z)); else tmp = Float64(x * 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -Inf) tmp = (-y * x) * z; elseif (((y * z) <= -5.0) || ~(((y * z) <= 5e-6))) tmp = x * (-y * z); else tmp = x * 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[(N[((-y) * x), $MachinePrecision] * z), $MachinePrecision], If[Or[LessEqual[N[(y * z), $MachinePrecision], -5.0], N[Not[LessEqual[N[(y * z), $MachinePrecision], 5e-6]], $MachinePrecision]], N[(x * N[((-y) * z), $MachinePrecision]), $MachinePrecision], N[(x * 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;\left(\left(-y\right) \cdot x\right) \cdot z\\
\mathbf{elif}\;y \cdot z \leq -5 \lor \neg \left(y \cdot z \leq 5 \cdot 10^{-6}\right):\\
\;\;\;\;x \cdot \left(\left(-y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1\\
\end{array}
\end{array}
if (*.f64 y z) < -inf.0Initial program 58.9%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6458.9
Applied rewrites58.9%
Applied rewrites58.9%
Applied rewrites58.9%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
if -inf.0 < (*.f64 y z) < -5 or 5.00000000000000041e-6 < (*.f64 y z) Initial program 96.2%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
if -5 < (*.f64 y z) < 5.00000000000000041e-6Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites99.3%
Final simplification97.2%
(FPCore (x y z) :precision binary64 (if (or (<= (* y z) -2e+33) (not (<= (* y z) 5e-6))) (* (* (- y) x) z) (* x 1.0)))
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+33) || !((y * z) <= 5e-6)) {
tmp = (-y * x) * z;
} else {
tmp = x * 1.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) :: tmp
if (((y * z) <= (-2d+33)) .or. (.not. ((y * z) <= 5d-6))) then
tmp = (-y * x) * z
else
tmp = x * 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+33) || !((y * z) <= 5e-6)) {
tmp = (-y * x) * z;
} else {
tmp = x * 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((y * z) <= -2e+33) or not ((y * z) <= 5e-6): tmp = (-y * x) * z else: tmp = x * 1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -2e+33) || !(Float64(y * z) <= 5e-6)) tmp = Float64(Float64(Float64(-y) * x) * z); else tmp = Float64(x * 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((y * z) <= -2e+33) || ~(((y * z) <= 5e-6))) tmp = (-y * x) * z; else tmp = x * 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -2e+33], N[Not[LessEqual[N[(y * z), $MachinePrecision], 5e-6]], $MachinePrecision]], N[(N[((-y) * x), $MachinePrecision] * z), $MachinePrecision], N[(x * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+33} \lor \neg \left(y \cdot z \leq 5 \cdot 10^{-6}\right):\\
\;\;\;\;\left(\left(-y\right) \cdot x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1\\
\end{array}
\end{array}
if (*.f64 y z) < -1.9999999999999999e33 or 5.00000000000000041e-6 < (*.f64 y z) Initial program 90.7%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6490.0
Applied rewrites90.0%
Applied rewrites62.5%
Applied rewrites89.9%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6495.2
Applied rewrites95.2%
if -1.9999999999999999e33 < (*.f64 y z) < 5.00000000000000041e-6Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites97.3%
Final simplification96.3%
(FPCore (x y z) :precision binary64 (* x 1.0))
double code(double x, double y, double z) {
return x * 1.0;
}
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
end function
public static double code(double x, double y, double z) {
return x * 1.0;
}
def code(x, y, z): return x * 1.0
function code(x, y, z) return Float64(x * 1.0) end
function tmp = code(x, y, z) tmp = x * 1.0; end
code[x_, y_, z_] := N[(x * 1.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 1
\end{array}
Initial program 95.5%
Taylor expanded in y around 0
Applied rewrites51.8%
herbie shell --seed 2024318
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))