
(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 (- 0.0 (* y (* z x)))))
(if (<= (* y z) -1.4e+197)
t_0
(if (<= (* y z) 5e+283) (- x (* (* y z) x)) t_0))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = 0.0 - (y * (z * x));
double tmp;
if ((y * z) <= -1.4e+197) {
tmp = t_0;
} else if ((y * z) <= 5e+283) {
tmp = x - ((y * z) * 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 = 0.0d0 - (y * (z * x))
if ((y * z) <= (-1.4d+197)) then
tmp = t_0
else if ((y * z) <= 5d+283) then
tmp = x - ((y * z) * 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 = 0.0 - (y * (z * x));
double tmp;
if ((y * z) <= -1.4e+197) {
tmp = t_0;
} else if ((y * z) <= 5e+283) {
tmp = x - ((y * z) * x);
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = 0.0 - (y * (z * x)) tmp = 0 if (y * z) <= -1.4e+197: tmp = t_0 elif (y * z) <= 5e+283: tmp = x - ((y * z) * x) else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(0.0 - Float64(y * Float64(z * x))) tmp = 0.0 if (Float64(y * z) <= -1.4e+197) tmp = t_0; elseif (Float64(y * z) <= 5e+283) tmp = Float64(x - Float64(Float64(y * z) * 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 = 0.0 - (y * (z * x));
tmp = 0.0;
if ((y * z) <= -1.4e+197)
tmp = t_0;
elseif ((y * z) <= 5e+283)
tmp = x - ((y * z) * 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[(0.0 - N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -1.4e+197], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 5e+283], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := 0 - y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;y \cdot z \leq -1.4 \cdot 10^{+197}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+283}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -1.3999999999999999e197 or 5.0000000000000004e283 < (*.f64 y z) Initial program 73.6%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6497.4%
Simplified97.4%
sub0-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6497.4%
Applied egg-rr97.4%
if -1.3999999999999999e197 < (*.f64 y z) < 5.0000000000000004e283Initial program 99.9%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
Final simplification99.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 0.0 (* y (* z x)))))
(if (<= (* y z) -1.4e+197)
t_0
(if (<= (* y z) 5e+283) (* x (- 1.0 (* y z))) t_0))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = 0.0 - (y * (z * x));
double tmp;
if ((y * z) <= -1.4e+197) {
tmp = t_0;
} else if ((y * z) <= 5e+283) {
tmp = x * (1.0 - (y * z));
} 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 = 0.0d0 - (y * (z * x))
if ((y * z) <= (-1.4d+197)) then
tmp = t_0
else if ((y * z) <= 5d+283) then
tmp = x * (1.0d0 - (y * z))
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 = 0.0 - (y * (z * x));
double tmp;
if ((y * z) <= -1.4e+197) {
tmp = t_0;
} else if ((y * z) <= 5e+283) {
tmp = x * (1.0 - (y * z));
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = 0.0 - (y * (z * x)) tmp = 0 if (y * z) <= -1.4e+197: tmp = t_0 elif (y * z) <= 5e+283: tmp = x * (1.0 - (y * z)) else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(0.0 - Float64(y * Float64(z * x))) tmp = 0.0 if (Float64(y * z) <= -1.4e+197) tmp = t_0; elseif (Float64(y * z) <= 5e+283) tmp = Float64(x * Float64(1.0 - Float64(y * z))); 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 = 0.0 - (y * (z * x));
tmp = 0.0;
if ((y * z) <= -1.4e+197)
tmp = t_0;
elseif ((y * z) <= 5e+283)
tmp = x * (1.0 - (y * z));
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[(0.0 - N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -1.4e+197], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 5e+283], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := 0 - y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;y \cdot z \leq -1.4 \cdot 10^{+197}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+283}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -1.3999999999999999e197 or 5.0000000000000004e283 < (*.f64 y z) Initial program 73.6%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6497.4%
Simplified97.4%
sub0-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6497.4%
Applied egg-rr97.4%
if -1.3999999999999999e197 < (*.f64 y z) < 5.0000000000000004e283Initial program 99.9%
Final simplification99.5%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y z) -2.0) (- 0.0 (* y (* z x))) (if (<= (* y z) 0.1) x (- 0.0 (* z (* y x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -2.0) {
tmp = 0.0 - (y * (z * x));
} else if ((y * z) <= 0.1) {
tmp = x;
} else {
tmp = 0.0 - (z * (y * x));
}
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) <= (-2.0d0)) then
tmp = 0.0d0 - (y * (z * x))
else if ((y * z) <= 0.1d0) then
tmp = x
else
tmp = 0.0d0 - (z * (y * x))
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) <= -2.0) {
tmp = 0.0 - (y * (z * x));
} else if ((y * z) <= 0.1) {
tmp = x;
} else {
tmp = 0.0 - (z * (y * x));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= -2.0: tmp = 0.0 - (y * (z * x)) elif (y * z) <= 0.1: tmp = x else: tmp = 0.0 - (z * (y * x)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -2.0) tmp = Float64(0.0 - Float64(y * Float64(z * x))); elseif (Float64(y * z) <= 0.1) tmp = x; else tmp = Float64(0.0 - Float64(z * Float64(y * x))); 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) <= -2.0)
tmp = 0.0 - (y * (z * x));
elseif ((y * z) <= 0.1)
tmp = x;
else
tmp = 0.0 - (z * (y * x));
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[(y * z), $MachinePrecision], -2.0], N[(0.0 - N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 0.1], x, N[(0.0 - N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -2:\\
\;\;\;\;0 - y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \cdot z \leq 0.1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0 - z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -2Initial program 90.0%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6488.0%
Simplified88.0%
sub0-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6488.0%
Applied egg-rr88.0%
if -2 < (*.f64 y z) < 0.10000000000000001Initial program 100.0%
Taylor expanded in y around 0
Simplified98.4%
if 0.10000000000000001 < (*.f64 y z) Initial program 92.4%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6488.3%
Simplified88.3%
sub0-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
*-commutativeN/A
*-lowering-*.f6490.4%
Applied egg-rr90.4%
Final simplification94.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (let* ((t_0 (- 0.0 (* z (* y x))))) (if (<= y -1.3e+117) t_0 (if (<= y 2.6e-85) x t_0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = 0.0 - (z * (y * x));
double tmp;
if (y <= -1.3e+117) {
tmp = t_0;
} else if (y <= 2.6e-85) {
tmp = 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 = 0.0d0 - (z * (y * x))
if (y <= (-1.3d+117)) then
tmp = t_0
else if (y <= 2.6d-85) then
tmp = 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 = 0.0 - (z * (y * x));
double tmp;
if (y <= -1.3e+117) {
tmp = t_0;
} else if (y <= 2.6e-85) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = 0.0 - (z * (y * x)) tmp = 0 if y <= -1.3e+117: tmp = t_0 elif y <= 2.6e-85: tmp = x else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(0.0 - Float64(z * Float64(y * x))) tmp = 0.0 if (y <= -1.3e+117) tmp = t_0; elseif (y <= 2.6e-85) tmp = 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 = 0.0 - (z * (y * x));
tmp = 0.0;
if (y <= -1.3e+117)
tmp = t_0;
elseif (y <= 2.6e-85)
tmp = 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[(0.0 - N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.3e+117], t$95$0, If[LessEqual[y, 2.6e-85], x, t$95$0]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := 0 - z \cdot \left(y \cdot x\right)\\
\mathbf{if}\;y \leq -1.3 \cdot 10^{+117}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-85}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.3e117 or 2.60000000000000011e-85 < y Initial program 93.1%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6464.3%
Simplified64.3%
sub0-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
*-commutativeN/A
*-lowering-*.f6466.3%
Applied egg-rr66.3%
if -1.3e117 < y < 2.60000000000000011e-85Initial program 98.5%
Taylor expanded in y around 0
Simplified75.8%
Final simplification71.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 x)
assert(x < y && y < z);
double code(double x, double y, double z) {
return x;
}
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
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return x;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return x
x, y, z = sort([x, y, z]) function code(x, y, z) return x end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = x;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := x
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x
\end{array}
Initial program 95.9%
Taylor expanded in y around 0
Simplified53.9%
herbie shell --seed 2024152
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))