
(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}
(FPCore (x y z) :precision binary64 (- x (* x (* y z))))
double code(double x, double y, double z) {
return x - (x * (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 - (x * (y * z))
end function
public static double code(double x, double y, double z) {
return x - (x * (y * z));
}
def code(x, y, z): return x - (x * (y * z))
function code(x, y, z) return Float64(x - Float64(x * Float64(y * z))) end
function tmp = code(x, y, z) tmp = x - (x * (y * z)); end
code[x_, y_, z_] := N[(x - N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - x \cdot \left(y \cdot z\right)
\end{array}
Initial program 97.3%
Taylor expanded in y around 0 97.3%
mul-1-neg97.3%
*-commutative97.3%
associate-*l*93.0%
*-commutative93.0%
Simplified93.0%
Taylor expanded in y around 0 97.3%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.45e-201) (not (<= z 1.4e+43))) (* x (* y (- z))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.45e-201) || !(z <= 1.4e+43)) {
tmp = x * (y * -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 <= (-2.45d-201)) .or. (.not. (z <= 1.4d+43))) then
tmp = x * (y * -z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.45e-201) || !(z <= 1.4e+43)) {
tmp = x * (y * -z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.45e-201) or not (z <= 1.4e+43): tmp = x * (y * -z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.45e-201) || !(z <= 1.4e+43)) tmp = Float64(x * Float64(y * Float64(-z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.45e-201) || ~((z <= 1.4e+43))) tmp = x * (y * -z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.45e-201], N[Not[LessEqual[z, 1.4e+43]], $MachinePrecision]], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.45 \cdot 10^{-201} \lor \neg \left(z \leq 1.4 \cdot 10^{+43}\right):\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.4499999999999998e-201 or 1.40000000000000009e43 < z Initial program 95.6%
Taylor expanded in y around inf 66.1%
associate-*r*66.1%
mul-1-neg66.1%
Simplified66.1%
if -2.4499999999999998e-201 < z < 1.40000000000000009e43Initial program 99.9%
Taylor expanded in y around 0 70.1%
Final simplification67.6%
(FPCore (x y z) :precision binary64 (if (<= z -2.45e-201) (* x (* y (- z))) (if (<= z 1.35e+43) x (* y (* x (- z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.45e-201) {
tmp = x * (y * -z);
} else if (z <= 1.35e+43) {
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 (z <= (-2.45d-201)) then
tmp = x * (y * -z)
else if (z <= 1.35d+43) 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 (z <= -2.45e-201) {
tmp = x * (y * -z);
} else if (z <= 1.35e+43) {
tmp = x;
} else {
tmp = y * (x * -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.45e-201: tmp = x * (y * -z) elif z <= 1.35e+43: tmp = x else: tmp = y * (x * -z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.45e-201) tmp = Float64(x * Float64(y * Float64(-z))); elseif (z <= 1.35e+43) 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 (z <= -2.45e-201) tmp = x * (y * -z); elseif (z <= 1.35e+43) tmp = x; else tmp = y * (x * -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.45e-201], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.35e+43], x, N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.45 \cdot 10^{-201}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{+43}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if z < -2.4499999999999998e-201Initial program 95.5%
Taylor expanded in y around inf 60.8%
associate-*r*60.8%
mul-1-neg60.8%
Simplified60.8%
if -2.4499999999999998e-201 < z < 1.3500000000000001e43Initial program 99.9%
Taylor expanded in y around 0 70.1%
if 1.3500000000000001e43 < z Initial program 95.9%
Taylor expanded in y around inf 78.0%
mul-1-neg78.0%
*-commutative78.0%
associate-*l*80.3%
*-commutative80.3%
distribute-rgt-neg-in80.3%
distribute-rgt-neg-in80.3%
Simplified80.3%
Final simplification68.0%
(FPCore (x y z) :precision binary64 (if (<= z 7.5e+104) x (/ (* x z) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= 7.5e+104) {
tmp = x;
} else {
tmp = (x * z) / 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 (z <= 7.5d+104) then
tmp = x
else
tmp = (x * z) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 7.5e+104) {
tmp = x;
} else {
tmp = (x * z) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 7.5e+104: tmp = x else: tmp = (x * z) / z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 7.5e+104) tmp = x; else tmp = Float64(Float64(x * z) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 7.5e+104) tmp = x; else tmp = (x * z) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 7.5e+104], x, N[(N[(x * z), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 7.5 \cdot 10^{+104}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot z}{z}\\
\end{array}
\end{array}
if z < 7.5000000000000002e104Initial program 97.7%
Taylor expanded in y around 0 51.2%
if 7.5000000000000002e104 < z Initial program 95.0%
Taylor expanded in y around 0 95.0%
Taylor expanded in z around inf 97.5%
+-commutative97.5%
mul-1-neg97.5%
sub-neg97.5%
Simplified97.5%
Taylor expanded in z around 0 18.8%
associate-*r/30.6%
*-commutative30.6%
Applied egg-rr30.6%
Final simplification48.0%
(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}
Initial program 97.3%
Final simplification97.3%
(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 97.3%
Taylor expanded in y around 0 46.2%
Final simplification46.2%
herbie shell --seed 2024078
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))