
(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 5 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
(let* ((t_0 (* (- z) (* x y))))
(if (<= (* z y) -5e+277)
t_0
(if (<= (* z y) 1e+197) (* (- 1.0 (* z y)) x) t_0))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = -z * (x * y);
double tmp;
if ((z * y) <= -5e+277) {
tmp = t_0;
} else if ((z * y) <= 1e+197) {
tmp = (1.0 - (z * y)) * x;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = -z * (x * y)
if ((z * y) <= (-5d+277)) then
tmp = t_0
else if ((z * y) <= 1d+197) then
tmp = (1.0d0 - (z * y)) * x
else
tmp = t_0
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = -z * (x * y);
double tmp;
if ((z * y) <= -5e+277) {
tmp = t_0;
} else if ((z * y) <= 1e+197) {
tmp = (1.0 - (z * y)) * x;
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = -z * (x * y) tmp = 0 if (z * y) <= -5e+277: tmp = t_0 elif (z * y) <= 1e+197: tmp = (1.0 - (z * y)) * x else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(Float64(-z) * Float64(x * y)) tmp = 0.0 if (Float64(z * y) <= -5e+277) tmp = t_0; elseif (Float64(z * y) <= 1e+197) tmp = Float64(Float64(1.0 - Float64(z * y)) * x); else tmp = t_0; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = -z * (x * y);
tmp = 0.0;
if ((z * y) <= -5e+277)
tmp = t_0;
elseif ((z * y) <= 1e+197)
tmp = (1.0 - (z * y)) * x;
else
tmp = t_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_] := Block[{t$95$0 = N[((-z) * N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * y), $MachinePrecision], -5e+277], t$95$0, If[LessEqual[N[(z * y), $MachinePrecision], 1e+197], N[(N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \left(-z\right) \cdot \left(x \cdot y\right)\\
\mathbf{if}\;z \cdot y \leq -5 \cdot 10^{+277}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \cdot y \leq 10^{+197}:\\
\;\;\;\;\left(1 - z \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -4.99999999999999982e277 or 9.9999999999999995e196 < (*.f64 y z) Initial program 65.3%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
if -4.99999999999999982e277 < (*.f64 y z) < 9.9999999999999995e196Initial 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 (<= (* z y) -5e+277)
(* (- z) (* x y))
(if (<= (* z y) -40000.0)
(* (* (- z) y) x)
(if (<= (* z y) 5e-9) (* 1.0 x) (* (* x z) (- y))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((z * y) <= -5e+277) {
tmp = -z * (x * y);
} else if ((z * y) <= -40000.0) {
tmp = (-z * y) * x;
} else if ((z * y) <= 5e-9) {
tmp = 1.0 * x;
} else {
tmp = (x * z) * -y;
}
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 ((z * y) <= (-5d+277)) then
tmp = -z * (x * y)
else if ((z * y) <= (-40000.0d0)) then
tmp = (-z * y) * x
else if ((z * y) <= 5d-9) then
tmp = 1.0d0 * x
else
tmp = (x * z) * -y
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((z * y) <= -5e+277) {
tmp = -z * (x * y);
} else if ((z * y) <= -40000.0) {
tmp = (-z * y) * x;
} else if ((z * y) <= 5e-9) {
tmp = 1.0 * x;
} else {
tmp = (x * z) * -y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (z * y) <= -5e+277: tmp = -z * (x * y) elif (z * y) <= -40000.0: tmp = (-z * y) * x elif (z * y) <= 5e-9: tmp = 1.0 * x else: tmp = (x * z) * -y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(z * y) <= -5e+277) tmp = Float64(Float64(-z) * Float64(x * y)); elseif (Float64(z * y) <= -40000.0) tmp = Float64(Float64(Float64(-z) * y) * x); elseif (Float64(z * y) <= 5e-9) tmp = Float64(1.0 * x); else tmp = Float64(Float64(x * z) * Float64(-y)); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * y) <= -5e+277)
tmp = -z * (x * y);
elseif ((z * y) <= -40000.0)
tmp = (-z * y) * x;
elseif ((z * y) <= 5e-9)
tmp = 1.0 * x;
else
tmp = (x * z) * -y;
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[LessEqual[N[(z * y), $MachinePrecision], -5e+277], N[((-z) * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * y), $MachinePrecision], -40000.0], N[(N[((-z) * y), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(z * y), $MachinePrecision], 5e-9], N[(1.0 * x), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * (-y)), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot y \leq -5 \cdot 10^{+277}:\\
\;\;\;\;\left(-z\right) \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;z \cdot y \leq -40000:\\
\;\;\;\;\left(\left(-z\right) \cdot y\right) \cdot x\\
\mathbf{elif}\;z \cdot y \leq 5 \cdot 10^{-9}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(-y\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -4.99999999999999982e277Initial program 75.5%
Taylor expanded in y around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
if -4.99999999999999982e277 < (*.f64 y z) < -4e4Initial program 99.7%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6498.2
Applied rewrites98.2%
if -4e4 < (*.f64 y z) < 5.0000000000000001e-9Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites98.1%
if 5.0000000000000001e-9 < (*.f64 y z) Initial program 93.2%
Applied rewrites36.3%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6488.0
Applied rewrites88.0%
Final simplification95.6%
herbie shell --seed 2024230
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))