
(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 (let* ((t_0 (- 1.0 (* y z)))) (if (<= t_0 5e+296) (* x t_0) (* y (* x (- z))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y * z);
double tmp;
if (t_0 <= 5e+296) {
tmp = x * t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (y * z)
if (t_0 <= 5d+296) then
tmp = x * t_0
else
tmp = y * (x * -z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y * z);
double tmp;
if (t_0 <= 5e+296) {
tmp = x * t_0;
} else {
tmp = y * (x * -z);
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y * z) tmp = 0 if t_0 <= 5e+296: tmp = x * t_0 else: tmp = y * (x * -z) return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y * z)) tmp = 0.0 if (t_0 <= 5e+296) tmp = Float64(x * t_0); else tmp = Float64(y * Float64(x * Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y * z); tmp = 0.0; if (t_0 <= 5e+296) tmp = x * t_0; else tmp = y * (x * -z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+296], N[(x * t$95$0), $MachinePrecision], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - y \cdot z\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+296}:\\
\;\;\;\;x \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if (-.f64 1 (*.f64 y z)) < 5.0000000000000001e296Initial program 98.2%
if 5.0000000000000001e296 < (-.f64 1 (*.f64 y z)) Initial program 75.4%
Taylor expanded in y around inf 99.9%
mul-1-neg99.9%
distribute-rgt-neg-in99.9%
distribute-lft-neg-out99.9%
*-commutative99.9%
Simplified99.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -6e-79) (not (<= z 4.2e+55))) (* x (* y (- z))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6e-79) || !(z <= 4.2e+55)) {
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 <= (-6d-79)) .or. (.not. (z <= 4.2d+55))) 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 <= -6e-79) || !(z <= 4.2e+55)) {
tmp = x * (y * -z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6e-79) or not (z <= 4.2e+55): tmp = x * (y * -z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6e-79) || !(z <= 4.2e+55)) 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 <= -6e-79) || ~((z <= 4.2e+55))) tmp = x * (y * -z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6e-79], N[Not[LessEqual[z, 4.2e+55]], $MachinePrecision]], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{-79} \lor \neg \left(z \leq 4.2 \cdot 10^{+55}\right):\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.99999999999999999e-79 or 4.2000000000000001e55 < z Initial program 92.1%
Taylor expanded in y around inf 75.0%
mul-1-neg75.0%
associate-*r*69.4%
distribute-lft-neg-in69.4%
distribute-rgt-neg-out69.4%
*-commutative69.4%
Simplified69.4%
if -5.99999999999999999e-79 < z < 4.2000000000000001e55Initial program 99.9%
Taylor expanded in y around 0 82.8%
Final simplification75.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.8e-79) (not (<= z 4.2e+55))) (* y (* x (- z))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.8e-79) || !(z <= 4.2e+55)) {
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 <= (-4.8d-79)) .or. (.not. (z <= 4.2d+55))) 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 <= -4.8e-79) || !(z <= 4.2e+55)) {
tmp = y * (x * -z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.8e-79) or not (z <= 4.2e+55): tmp = y * (x * -z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.8e-79) || !(z <= 4.2e+55)) tmp = Float64(y * Float64(x * Float64(-z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.8e-79) || ~((z <= 4.2e+55))) tmp = y * (x * -z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.8e-79], N[Not[LessEqual[z, 4.2e+55]], $MachinePrecision]], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{-79} \lor \neg \left(z \leq 4.2 \cdot 10^{+55}\right):\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.80000000000000011e-79 or 4.2000000000000001e55 < z Initial program 92.1%
Taylor expanded in y around inf 75.0%
mul-1-neg75.0%
distribute-rgt-neg-in75.0%
distribute-lft-neg-out75.0%
*-commutative75.0%
Simplified75.0%
if -4.80000000000000011e-79 < z < 4.2000000000000001e55Initial program 99.9%
Taylor expanded in y around 0 82.8%
Final simplification78.7%
(FPCore (x y z) :precision binary64 (- x (* y (* x z))))
double code(double x, double y, double z) {
return x - (y * (x * 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 - (y * (x * z))
end function
public static double code(double x, double y, double z) {
return x - (y * (x * z));
}
def code(x, y, z): return x - (y * (x * z))
function code(x, y, z) return Float64(x - Float64(y * Float64(x * z))) end
function tmp = code(x, y, z) tmp = x - (y * (x * z)); end
code[x_, y_, z_] := N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot \left(x \cdot z\right)
\end{array}
Initial program 95.8%
Taylor expanded in x around 0 95.8%
*-commutative95.8%
distribute-rgt-out--95.9%
associate-*r*94.3%
*-lft-identity94.3%
Simplified94.3%
Final simplification94.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 95.8%
Taylor expanded in y around 0 52.4%
Final simplification52.4%
herbie shell --seed 2023200
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))