
(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 (- 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%
sub-neg97.3%
distribute-rgt-in97.3%
*-un-lft-identity97.3%
distribute-rgt-neg-in97.3%
Applied egg-rr97.3%
associate-*l*92.5%
distribute-lft-neg-in92.5%
*-commutative92.5%
distribute-rgt-neg-out92.5%
distribute-lft-neg-in92.5%
add-sqr-sqrt50.7%
sqrt-unprod62.8%
sqr-neg62.8%
sqrt-unprod29.6%
add-sqr-sqrt50.1%
*-commutative50.1%
distribute-lft-neg-in50.1%
cancel-sign-sub-inv50.1%
associate-*l*53.2%
*-commutative53.2%
associate-*r*52.2%
*-commutative52.2%
associate-*r*50.1%
distribute-rgt-neg-in50.1%
add-sqr-sqrt29.6%
sqrt-unprod62.8%
Applied egg-rr92.5%
Taylor expanded in y around 0 97.3%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.8e-91) (not (<= z 5.1e+106))) (* z (* y (- x))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.8e-91) || !(z <= 5.1e+106)) {
tmp = z * (y * -x);
} 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.8d-91)) .or. (.not. (z <= 5.1d+106))) then
tmp = z * (y * -x)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.8e-91) || !(z <= 5.1e+106)) {
tmp = z * (y * -x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.8e-91) or not (z <= 5.1e+106): tmp = z * (y * -x) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.8e-91) || !(z <= 5.1e+106)) tmp = Float64(z * Float64(y * Float64(-x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.8e-91) || ~((z <= 5.1e+106))) tmp = z * (y * -x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.8e-91], N[Not[LessEqual[z, 5.1e+106]], $MachinePrecision]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{-91} \lor \neg \left(z \leq 5.1 \cdot 10^{+106}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.8e-91 or 5.09999999999999971e106 < z Initial program 94.7%
Taylor expanded in y around inf 64.6%
mul-1-neg64.6%
associate-*r*65.2%
Simplified65.2%
if -1.8e-91 < z < 5.09999999999999971e106Initial program 99.9%
Taylor expanded in y around 0 77.7%
Final simplification71.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.16e-67) (* y (* z (- x))) (if (<= z 5.1e+106) x (* z (* y (- x))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.16e-67) {
tmp = y * (z * -x);
} else if (z <= 5.1e+106) {
tmp = x;
} else {
tmp = z * (y * -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.16d-67)) then
tmp = y * (z * -x)
else if (z <= 5.1d+106) then
tmp = x
else
tmp = z * (y * -x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.16e-67) {
tmp = y * (z * -x);
} else if (z <= 5.1e+106) {
tmp = x;
} else {
tmp = z * (y * -x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.16e-67: tmp = y * (z * -x) elif z <= 5.1e+106: tmp = x else: tmp = z * (y * -x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.16e-67) tmp = Float64(y * Float64(z * Float64(-x))); elseif (z <= 5.1e+106) tmp = x; else tmp = Float64(z * Float64(y * Float64(-x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.16e-67) tmp = y * (z * -x); elseif (z <= 5.1e+106) tmp = x; else tmp = z * (y * -x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.16e-67], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.1e+106], x, N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.16 \cdot 10^{-67}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{+106}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\end{array}
\end{array}
if z < -1.16e-67Initial program 96.4%
Taylor expanded in y around inf 61.9%
mul-1-neg61.9%
associate-*r*61.4%
distribute-rgt-neg-in61.4%
*-commutative61.4%
associate-*r*61.4%
distribute-rgt-neg-out61.4%
Simplified61.4%
if -1.16e-67 < z < 5.09999999999999971e106Initial program 99.9%
Taylor expanded in y around 0 77.5%
if 5.09999999999999971e106 < z Initial program 90.2%
Taylor expanded in y around inf 77.7%
mul-1-neg77.7%
associate-*r*80.7%
Simplified80.7%
Final simplification73.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 54.3%
Final simplification54.3%
herbie shell --seed 2023326
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))