
(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}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= (* y z) -5e+300) (not (<= (* y z) 1e+273))) (fma (* x (- y)) z x) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -5e+300) || !((y * z) <= 1e+273)) {
tmp = fma((x * -y), z, x);
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -5e+300) || !(Float64(y * z) <= 1e+273)) tmp = fma(Float64(x * Float64(-y)), z, x); else tmp = Float64(x * Float64(1.0 - Float64(y * z))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -5e+300], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1e+273]], $MachinePrecision]], N[(N[(x * (-y)), $MachinePrecision] * z + x), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+300} \lor \neg \left(y \cdot z \leq 10^{+273}\right):\\
\;\;\;\;\mathsf{fma}\left(x \cdot \left(-y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -5.00000000000000026e300 or 9.99999999999999945e272 < (*.f64 y z) Initial program 70.9%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
if -5.00000000000000026e300 < (*.f64 y z) < 9.99999999999999945e272Initial program 99.8%
Final simplification99.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (or (<= (* y z) -10.0) (not (<= (* y z) 4e-9))) (* x (* (- y) z)) (* x 1.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -10.0) || !((y * z) <= 4e-9)) {
tmp = x * (-y * z);
} else {
tmp = x * 1.0;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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) <= (-10.0d0)) .or. (.not. ((y * z) <= 4d-9))) then
tmp = x * (-y * z)
else
tmp = x * 1.0d0
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -10.0) || !((y * z) <= 4e-9)) {
tmp = x * (-y * z);
} else {
tmp = x * 1.0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if ((y * z) <= -10.0) or not ((y * z) <= 4e-9): tmp = x * (-y * z) else: tmp = x * 1.0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -10.0) || !(Float64(y * z) <= 4e-9)) tmp = Float64(x * Float64(Float64(-y) * z)); else tmp = Float64(x * 1.0); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (((y * z) <= -10.0) || ~(((y * z) <= 4e-9)))
tmp = x * (-y * z);
else
tmp = x * 1.0;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -10.0], N[Not[LessEqual[N[(y * z), $MachinePrecision], 4e-9]], $MachinePrecision]], N[(x * N[((-y) * z), $MachinePrecision]), $MachinePrecision], N[(x * 1.0), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -10 \lor \neg \left(y \cdot z \leq 4 \cdot 10^{-9}\right):\\
\;\;\;\;x \cdot \left(\left(-y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1\\
\end{array}
\end{array}
if (*.f64 y z) < -10 or 4.00000000000000025e-9 < (*.f64 y z) Initial program 90.8%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6489.0
Applied rewrites89.0%
if -10 < (*.f64 y z) < 4.00000000000000025e-9Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites97.8%
Final simplification93.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x * (1.0 - (y * z))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x * (1.0 - (y * z));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
Initial program 95.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* x 1.0))
assert(x < y && y < z);
double code(double x, double y, double z) {
return x * 1.0;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x * 1.0;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x * 1.0
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(x * 1.0) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x * 1.0;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x * 1.0), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x \cdot 1
\end{array}
Initial program 95.1%
Taylor expanded in y around 0
Applied rewrites47.6%
herbie shell --seed 2024313
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))