
(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}
(FPCore (x y z) :precision binary64 (if (or (<= (* y z) -2e+301) (not (<= (* y z) 1e+132))) (* (* y x) (- z)) (- x (* (* y z) x))))
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+301) || !((y * z) <= 1e+132)) {
tmp = (y * x) * -z;
} else {
tmp = x - ((y * z) * x);
}
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+301)) .or. (.not. ((y * z) <= 1d+132))) then
tmp = (y * x) * -z
else
tmp = x - ((y * z) * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+301) || !((y * z) <= 1e+132)) {
tmp = (y * x) * -z;
} else {
tmp = x - ((y * z) * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((y * z) <= -2e+301) or not ((y * z) <= 1e+132): tmp = (y * x) * -z else: tmp = x - ((y * z) * x) return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -2e+301) || !(Float64(y * z) <= 1e+132)) tmp = Float64(Float64(y * x) * Float64(-z)); else tmp = Float64(x - Float64(Float64(y * z) * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((y * z) <= -2e+301) || ~(((y * z) <= 1e+132))) tmp = (y * x) * -z; else tmp = x - ((y * z) * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -2e+301], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1e+132]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] * (-z)), $MachinePrecision], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+301} \lor \neg \left(y \cdot z \leq 10^{+132}\right):\\
\;\;\;\;\left(y \cdot x\right) \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\
\end{array}
\end{array}
if (*.f64 y z) < -2.00000000000000011e301 or 9.99999999999999991e131 < (*.f64 y z) Initial program 78.2%
Taylor expanded in y around inf 78.2%
mul-1-neg78.2%
associate-*r*99.9%
Simplified99.9%
if -2.00000000000000011e301 < (*.f64 y z) < 9.99999999999999991e131Initial program 99.9%
Taylor expanded in y around 0 99.9%
mul-1-neg99.9%
associate-*r*91.0%
Simplified91.0%
unsub-neg91.0%
associate-*l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= (* y z) -2e+301) (not (<= (* y z) 1e+132))) (* (* y x) (- z)) (* x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+301) || !((y * z) <= 1e+132)) {
tmp = (y * x) * -z;
} else {
tmp = x * (1.0 - (y * z));
}
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+301)) .or. (.not. ((y * z) <= 1d+132))) then
tmp = (y * x) * -z
else
tmp = x * (1.0d0 - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2e+301) || !((y * z) <= 1e+132)) {
tmp = (y * x) * -z;
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((y * z) <= -2e+301) or not ((y * z) <= 1e+132): 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) <= -2e+301) || !(Float64(y * z) <= 1e+132)) tmp = Float64(Float64(y * x) * Float64(-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) <= -2e+301) || ~(((y * z) <= 1e+132))) tmp = (y * x) * -z; else tmp = x * (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -2e+301], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1e+132]], $MachinePrecision]], 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 -2 \cdot 10^{+301} \lor \neg \left(y \cdot z \leq 10^{+132}\right):\\
\;\;\;\;\left(y \cdot x\right) \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -2.00000000000000011e301 or 9.99999999999999991e131 < (*.f64 y z) Initial program 78.2%
Taylor expanded in y around inf 78.2%
mul-1-neg78.2%
associate-*r*99.9%
Simplified99.9%
if -2.00000000000000011e301 < (*.f64 y z) < 9.99999999999999991e131Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= (* y z) -5e+19) (* (* y x) (- z)) (if (<= (* y z) 0.005) x (* y (* x (- z))))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -5e+19) {
tmp = (y * x) * -z;
} else if ((y * z) <= 0.005) {
tmp = x;
} else {
tmp = y * (x * -z);
}
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) <= (-5d+19)) then
tmp = (y * x) * -z
else if ((y * z) <= 0.005d0) then
tmp = x
else
tmp = y * (x * -z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -5e+19) {
tmp = (y * x) * -z;
} else if ((y * z) <= 0.005) {
tmp = x;
} else {
tmp = y * (x * -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -5e+19: tmp = (y * x) * -z elif (y * z) <= 0.005: tmp = x else: tmp = y * (x * -z) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -5e+19) tmp = Float64(Float64(y * x) * Float64(-z)); elseif (Float64(y * z) <= 0.005) tmp = x; else tmp = Float64(y * Float64(x * Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -5e+19) tmp = (y * x) * -z; elseif ((y * z) <= 0.005) tmp = x; else tmp = y * (x * -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -5e+19], N[(N[(y * x), $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 0.005], x, N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+19}:\\
\;\;\;\;\left(y \cdot x\right) \cdot \left(-z\right)\\
\mathbf{elif}\;y \cdot z \leq 0.005:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -5e19Initial program 91.7%
Taylor expanded in y around inf 91.7%
mul-1-neg91.7%
associate-*r*91.5%
Simplified91.5%
if -5e19 < (*.f64 y z) < 0.0050000000000000001Initial program 100.0%
Taylor expanded in y around 0 98.6%
if 0.0050000000000000001 < (*.f64 y z) Initial program 87.8%
Taylor expanded in y around inf 85.5%
mul-1-neg85.5%
associate-*r*91.2%
distribute-rgt-neg-in91.2%
*-commutative91.2%
associate-*r*91.3%
Simplified91.3%
Final simplification94.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.72e-71) (not (<= z 135000000000.0))) (* (* y x) (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.72e-71) || !(z <= 135000000000.0)) {
tmp = (y * x) * -z;
} else {
tmp = x;
}
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 ((z <= (-1.72d-71)) .or. (.not. (z <= 135000000000.0d0))) then
tmp = (y * x) * -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.72e-71) || !(z <= 135000000000.0)) {
tmp = (y * x) * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.72e-71) or not (z <= 135000000000.0): tmp = (y * x) * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.72e-71) || !(z <= 135000000000.0)) tmp = Float64(Float64(y * x) * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.72e-71) || ~((z <= 135000000000.0))) tmp = (y * x) * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.72e-71], N[Not[LessEqual[z, 135000000000.0]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.72 \cdot 10^{-71} \lor \neg \left(z \leq 135000000000\right):\\
\;\;\;\;\left(y \cdot x\right) \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.72e-71 or 1.35e11 < z Initial program 89.6%
Taylor expanded in y around inf 68.5%
mul-1-neg68.5%
associate-*r*75.1%
Simplified75.1%
if -1.72e-71 < z < 1.35e11Initial program 99.9%
Taylor expanded in y around 0 75.8%
Final simplification75.4%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
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
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 94.4%
Taylor expanded in y around 0 47.9%
Final simplification47.9%
herbie shell --seed 2024048
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))