
(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 (<= (* y z) 4e+121) (- x (* (* y z) x)) (* z (* x (- y)))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= 4e+121) {
tmp = x - ((y * z) * x);
} else {
tmp = z * (x * -y);
}
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) <= 4d+121) then
tmp = x - ((y * z) * x)
else
tmp = z * (x * -y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= 4e+121) {
tmp = x - ((y * z) * x);
} else {
tmp = z * (x * -y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= 4e+121: tmp = x - ((y * z) * x) else: tmp = z * (x * -y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= 4e+121) tmp = Float64(x - Float64(Float64(y * z) * x)); else tmp = Float64(z * Float64(x * Float64(-y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= 4e+121) tmp = x - ((y * z) * x); else tmp = z * (x * -y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], 4e+121], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq 4 \cdot 10^{+121}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < 4.00000000000000015e121Initial program 98.2%
sub-neg98.2%
distribute-rgt-in98.2%
*-un-lft-identity98.2%
distribute-rgt-neg-in98.2%
Applied egg-rr98.2%
if 4.00000000000000015e121 < (*.f64 y z) Initial program 83.7%
Taylor expanded in y around inf 83.7%
mul-1-neg83.7%
associate-*r*99.8%
Simplified99.8%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.8e+69) (not (<= y 1.55e-71))) (* z (* x (- y))) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.8e+69) || !(y <= 1.55e-71)) {
tmp = z * (x * -y);
} 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 ((y <= (-1.8d+69)) .or. (.not. (y <= 1.55d-71))) then
tmp = z * (x * -y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.8e+69) || !(y <= 1.55e-71)) {
tmp = z * (x * -y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.8e+69) or not (y <= 1.55e-71): tmp = z * (x * -y) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.8e+69) || !(y <= 1.55e-71)) tmp = Float64(z * Float64(x * Float64(-y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.8e+69) || ~((y <= 1.55e-71))) tmp = z * (x * -y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.8e+69], N[Not[LessEqual[y, 1.55e-71]], $MachinePrecision]], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+69} \lor \neg \left(y \leq 1.55 \cdot 10^{-71}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.8000000000000001e69 or 1.55000000000000001e-71 < y Initial program 92.4%
Taylor expanded in y around inf 66.7%
mul-1-neg66.7%
associate-*r*70.7%
Simplified70.7%
if -1.8000000000000001e69 < y < 1.55000000000000001e-71Initial program 99.9%
Taylor expanded in y around 0 69.4%
Final simplification70.0%
(FPCore (x y z) :precision binary64 (if (<= y -6e+68) (* x (* y (- z))) (if (<= y 2.5e-71) x (* z (* x (- y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e+68) {
tmp = x * (y * -z);
} else if (y <= 2.5e-71) {
tmp = x;
} else {
tmp = z * (x * -y);
}
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 <= (-6d+68)) then
tmp = x * (y * -z)
else if (y <= 2.5d-71) then
tmp = x
else
tmp = z * (x * -y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6e+68) {
tmp = x * (y * -z);
} else if (y <= 2.5e-71) {
tmp = x;
} else {
tmp = z * (x * -y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e+68: tmp = x * (y * -z) elif y <= 2.5e-71: tmp = x else: tmp = z * (x * -y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e+68) tmp = Float64(x * Float64(y * Float64(-z))); elseif (y <= 2.5e-71) tmp = x; else tmp = Float64(z * Float64(x * Float64(-y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6e+68) tmp = x * (y * -z); elseif (y <= 2.5e-71) tmp = x; else tmp = z * (x * -y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e+68], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e-71], x, N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+68}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-71}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < -6.0000000000000004e68Initial program 95.5%
Taylor expanded in y around inf 81.4%
mul-1-neg81.4%
distribute-rgt-neg-in81.4%
distribute-rgt-neg-out81.4%
Simplified81.4%
if -6.0000000000000004e68 < y < 2.49999999999999999e-71Initial program 99.9%
Taylor expanded in y around 0 69.4%
if 2.49999999999999999e-71 < y Initial program 90.8%
Taylor expanded in y around inf 59.1%
mul-1-neg59.1%
associate-*r*65.2%
Simplified65.2%
Final simplification70.1%
(FPCore (x y z) :precision binary64 (if (<= (* y z) 4e+121) (* x (- 1.0 (* y z))) (* z (* x (- y)))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= 4e+121) {
tmp = x * (1.0 - (y * z));
} else {
tmp = z * (x * -y);
}
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) <= 4d+121) then
tmp = x * (1.0d0 - (y * z))
else
tmp = z * (x * -y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= 4e+121) {
tmp = x * (1.0 - (y * z));
} else {
tmp = z * (x * -y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= 4e+121: tmp = x * (1.0 - (y * z)) else: tmp = z * (x * -y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= 4e+121) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = Float64(z * Float64(x * Float64(-y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= 4e+121) tmp = x * (1.0 - (y * z)); else tmp = z * (x * -y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], 4e+121], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq 4 \cdot 10^{+121}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < 4.00000000000000015e121Initial program 98.2%
if 4.00000000000000015e121 < (*.f64 y z) Initial program 83.7%
Taylor expanded in y around inf 83.7%
mul-1-neg83.7%
associate-*r*99.8%
Simplified99.8%
Final simplification98.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 96.2%
Taylor expanded in y around 0 49.1%
Final simplification49.1%
herbie shell --seed 2024040
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))