
(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 6 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+75) (not (<= (* y z) 2e+297))) (* y (* x (- z))) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -5e+75) || !((y * z) <= 2e+297)) {
tmp = y * (x * -z);
} else {
tmp = x * (1.0 - (y * z));
}
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) <= (-5d+75)) .or. (.not. ((y * z) <= 2d+297))) then
tmp = y * (x * -z)
else
tmp = x * (1.0d0 - (y * z))
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) <= -5e+75) || !((y * z) <= 2e+297)) {
tmp = y * (x * -z);
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if ((y * z) <= -5e+75) or not ((y * z) <= 2e+297): tmp = y * (x * -z) 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+75) || !(Float64(y * z) <= 2e+297)) tmp = Float64(y * Float64(x * Float64(-z))); else tmp = Float64(x * Float64(1.0 - Float64(y * z))); 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) <= -5e+75) || ~(((y * z) <= 2e+297)))
tmp = y * (x * -z);
else
tmp = x * (1.0 - (y * z));
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], -5e+75], N[Not[LessEqual[N[(y * z), $MachinePrecision], 2e+297]], $MachinePrecision]], N[(y * N[(x * (-z)), $MachinePrecision]), $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^{+75} \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+297}\right):\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -5.0000000000000002e75 or 2e297 < (*.f64 y z) Initial program 83.6%
Taylor expanded in y around inf 83.6%
mul-1-neg83.6%
associate-*r*99.8%
distribute-rgt-neg-in99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if -5.0000000000000002e75 < (*.f64 y z) < 2e297Initial program 99.9%
Final simplification99.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (* x y) z))))
(if (<= (* y z) -1.0)
t_0
(if (<= (* y z) 0.1) x (if (<= (* y z) 2e+203) (* x (* z (- y))) t_0)))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = -((x * y) * z);
double tmp;
if ((y * z) <= -1.0) {
tmp = t_0;
} else if ((y * z) <= 0.1) {
tmp = x;
} else if ((y * z) <= 2e+203) {
tmp = x * (z * -y);
} 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 = -((x * y) * z)
if ((y * z) <= (-1.0d0)) then
tmp = t_0
else if ((y * z) <= 0.1d0) then
tmp = x
else if ((y * z) <= 2d+203) then
tmp = x * (z * -y)
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 = -((x * y) * z);
double tmp;
if ((y * z) <= -1.0) {
tmp = t_0;
} else if ((y * z) <= 0.1) {
tmp = x;
} else if ((y * z) <= 2e+203) {
tmp = x * (z * -y);
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = -((x * y) * z) tmp = 0 if (y * z) <= -1.0: tmp = t_0 elif (y * z) <= 0.1: tmp = x elif (y * z) <= 2e+203: tmp = x * (z * -y) else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(-Float64(Float64(x * y) * z)) tmp = 0.0 if (Float64(y * z) <= -1.0) tmp = t_0; elseif (Float64(y * z) <= 0.1) tmp = x; elseif (Float64(y * z) <= 2e+203) tmp = Float64(x * Float64(z * Float64(-y))); 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 = -((x * y) * z);
tmp = 0.0;
if ((y * z) <= -1.0)
tmp = t_0;
elseif ((y * z) <= 0.1)
tmp = x;
elseif ((y * z) <= 2e+203)
tmp = x * (z * -y);
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[(N[(x * y), $MachinePrecision] * z), $MachinePrecision])}, If[LessEqual[N[(y * z), $MachinePrecision], -1.0], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 0.1], x, If[LessEqual[N[(y * z), $MachinePrecision], 2e+203], N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := -\left(x \cdot y\right) \cdot z\\
\mathbf{if}\;y \cdot z \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 0.1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+203}:\\
\;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -1 or 2e203 < (*.f64 y z) Initial program 87.2%
Taylor expanded in y around inf 85.3%
mul-1-neg85.3%
associate-*r*94.8%
Simplified94.8%
if -1 < (*.f64 y z) < 0.10000000000000001Initial program 100.0%
Taylor expanded in y around 0 98.3%
if 0.10000000000000001 < (*.f64 y z) < 2e203Initial program 99.6%
Taylor expanded in y around inf 96.7%
mul-1-neg96.7%
associate-*r*80.4%
Simplified80.4%
Taylor expanded in x around 0 96.7%
Final simplification97.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= (* y z) -1.0)
(- (* (* x y) z))
(if (<= (* y z) 0.1)
x
(if (<= (* y z) 2e+297) (* x (* z (- y))) (* y (* x (- z)))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -1.0) {
tmp = -((x * y) * z);
} else if ((y * z) <= 0.1) {
tmp = x;
} else if ((y * z) <= 2e+297) {
tmp = x * (z * -y);
} else {
tmp = y * (x * -z);
}
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) <= (-1.0d0)) then
tmp = -((x * y) * z)
else if ((y * z) <= 0.1d0) then
tmp = x
else if ((y * z) <= 2d+297) then
tmp = x * (z * -y)
else
tmp = y * (x * -z)
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) <= -1.0) {
tmp = -((x * y) * z);
} else if ((y * z) <= 0.1) {
tmp = x;
} else if ((y * z) <= 2e+297) {
tmp = x * (z * -y);
} else {
tmp = y * (x * -z);
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (y * z) <= -1.0: tmp = -((x * y) * z) elif (y * z) <= 0.1: tmp = x elif (y * z) <= 2e+297: tmp = x * (z * -y) else: tmp = y * (x * -z) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -1.0) tmp = Float64(-Float64(Float64(x * y) * z)); elseif (Float64(y * z) <= 0.1) tmp = x; elseif (Float64(y * z) <= 2e+297) tmp = Float64(x * Float64(z * Float64(-y))); else tmp = Float64(y * Float64(x * Float64(-z))); 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) <= -1.0)
tmp = -((x * y) * z);
elseif ((y * z) <= 0.1)
tmp = x;
elseif ((y * z) <= 2e+297)
tmp = x * (z * -y);
else
tmp = y * (x * -z);
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], -1.0], (-N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision]), If[LessEqual[N[(y * z), $MachinePrecision], 0.1], x, If[LessEqual[N[(y * z), $MachinePrecision], 2e+297], N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1:\\
\;\;\;\;-\left(x \cdot y\right) \cdot z\\
\mathbf{elif}\;y \cdot z \leq 0.1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+297}:\\
\;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -1Initial program 91.9%
Taylor expanded in y around inf 89.3%
mul-1-neg89.3%
associate-*r*93.0%
Simplified93.0%
if -1 < (*.f64 y z) < 0.10000000000000001Initial program 100.0%
Taylor expanded in y around 0 98.3%
if 0.10000000000000001 < (*.f64 y z) < 2e297Initial program 99.6%
Taylor expanded in y around inf 97.1%
mul-1-neg97.1%
associate-*r*83.0%
Simplified83.0%
Taylor expanded in x around 0 97.1%
if 2e297 < (*.f64 y z) Initial program 66.7%
Taylor expanded in y around inf 66.7%
mul-1-neg66.7%
associate-*r*99.8%
distribute-rgt-neg-in99.8%
*-commutative99.8%
associate-*l*99.9%
Simplified99.9%
Final simplification97.0%
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) -1.0) (not (<= (* y z) 1.0))) (* x (* z (- y))) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -1.0) || !((y * z) <= 1.0)) {
tmp = x * (z * -y);
} else {
tmp = 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) <= (-1.0d0)) .or. (.not. ((y * z) <= 1.0d0))) then
tmp = x * (z * -y)
else
tmp = 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) <= -1.0) || !((y * z) <= 1.0)) {
tmp = x * (z * -y);
} else {
tmp = x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if ((y * z) <= -1.0) or not ((y * z) <= 1.0): tmp = x * (z * -y) else: tmp = x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -1.0) || !(Float64(y * z) <= 1.0)) tmp = Float64(x * Float64(z * Float64(-y))); else tmp = 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) <= -1.0) || ~(((y * z) <= 1.0)))
tmp = x * (z * -y);
else
tmp = 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[Or[LessEqual[N[(y * z), $MachinePrecision], -1.0], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1.0]], $MachinePrecision]], N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1 \lor \neg \left(y \cdot z \leq 1\right):\\
\;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (*.f64 y z) < -1 or 1 < (*.f64 y z) Initial program 90.8%
Taylor expanded in y around inf 88.6%
mul-1-neg88.6%
associate-*r*90.6%
Simplified90.6%
Taylor expanded in x around 0 88.6%
if -1 < (*.f64 y z) < 1Initial program 100.0%
Taylor expanded in y around 0 98.3%
Final simplification93.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= x 5e+45) (- x (* (* x y) z)) (- x (* x (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (x <= 5e+45) {
tmp = x - ((x * y) * z);
} else {
tmp = x - (x * (y * z));
}
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 (x <= 5d+45) then
tmp = x - ((x * y) * z)
else
tmp = x - (x * (y * z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (x <= 5e+45) {
tmp = x - ((x * y) * z);
} else {
tmp = x - (x * (y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if x <= 5e+45: tmp = x - ((x * y) * z) else: tmp = x - (x * (y * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (x <= 5e+45) tmp = Float64(x - Float64(Float64(x * y) * z)); else tmp = Float64(x - Float64(x * Float64(y * z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (x <= 5e+45)
tmp = x - ((x * y) * z);
else
tmp = x - (x * (y * z));
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[x, 5e+45], N[(x - N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+45}:\\
\;\;\;\;x - \left(x \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if x < 5e45Initial program 94.6%
Taylor expanded in y around 0 94.6%
mul-1-neg94.6%
associate-*r*96.4%
Simplified96.4%
if 5e45 < x Initial program 99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-rgt-neg-in99.9%
Applied egg-rr99.9%
*-commutative99.9%
associate-*r*85.9%
distribute-rgt-neg-in85.9%
unsub-neg85.9%
*-commutative85.9%
associate-*l*93.8%
*-commutative93.8%
Applied egg-rr93.8%
Taylor expanded in y around 0 99.9%
Final simplification97.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.8%
Taylor expanded in y around 0 55.4%
Final simplification55.4%
herbie shell --seed 2024095
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))