
(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.0%
sub-neg97.0%
distribute-rgt-in97.0%
*-un-lft-identity97.0%
distribute-rgt-neg-in97.0%
Applied egg-rr97.0%
*-commutative97.0%
associate-*r*92.6%
distribute-rgt-neg-in92.6%
unsub-neg92.6%
*-commutative92.6%
associate-*r*92.9%
*-commutative92.9%
Applied egg-rr92.9%
Taylor expanded in y around 0 97.0%
Final simplification97.0%
(FPCore (x y z)
:precision binary64
(if (or (<= y -1.85e+139)
(not
(or (<= y -1.25e+132) (and (not (<= y -1.4e+75)) (<= y 1.3e-98)))))
(- (* z (* x y)))
x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.85e+139) || !((y <= -1.25e+132) || (!(y <= -1.4e+75) && (y <= 1.3e-98)))) {
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.85d+139)) .or. (.not. (y <= (-1.25d+132)) .or. (.not. (y <= (-1.4d+75))) .and. (y <= 1.3d-98))) 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.85e+139) || !((y <= -1.25e+132) || (!(y <= -1.4e+75) && (y <= 1.3e-98)))) {
tmp = -(z * (x * y));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.85e+139) or not ((y <= -1.25e+132) or (not (y <= -1.4e+75) and (y <= 1.3e-98))): tmp = -(z * (x * y)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.85e+139) || !((y <= -1.25e+132) || (!(y <= -1.4e+75) && (y <= 1.3e-98)))) tmp = Float64(-Float64(z * Float64(x * y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.85e+139) || ~(((y <= -1.25e+132) || (~((y <= -1.4e+75)) && (y <= 1.3e-98))))) tmp = -(z * (x * y)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.85e+139], N[Not[Or[LessEqual[y, -1.25e+132], And[N[Not[LessEqual[y, -1.4e+75]], $MachinePrecision], LessEqual[y, 1.3e-98]]]], $MachinePrecision]], (-N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{+139} \lor \neg \left(y \leq -1.25 \cdot 10^{+132} \lor \neg \left(y \leq -1.4 \cdot 10^{+75}\right) \land y \leq 1.3 \cdot 10^{-98}\right):\\
\;\;\;\;-z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.84999999999999996e139 or -1.25e132 < y < -1.40000000000000006e75 or 1.30000000000000007e-98 < y Initial program 94.9%
Taylor expanded in y around inf 68.4%
mul-1-neg68.4%
associate-*r*67.8%
Simplified67.8%
if -1.84999999999999996e139 < y < -1.25e132 or -1.40000000000000006e75 < y < 1.30000000000000007e-98Initial program 99.2%
Taylor expanded in y around 0 75.5%
Final simplification71.5%
(FPCore (x y z)
:precision binary64
(if (<= y -2.5e+139)
(- (* z (* x y)))
(if (or (<= y -1.25e+132) (and (not (<= y -6.2e+75)) (<= y 1.8e-100)))
x
(* y (* z (- x))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.5e+139) {
tmp = -(z * (x * y));
} else if ((y <= -1.25e+132) || (!(y <= -6.2e+75) && (y <= 1.8e-100))) {
tmp = x;
} else {
tmp = 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 <= (-2.5d+139)) then
tmp = -(z * (x * y))
else if ((y <= (-1.25d+132)) .or. (.not. (y <= (-6.2d+75))) .and. (y <= 1.8d-100)) then
tmp = x
else
tmp = y * (z * -x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.5e+139) {
tmp = -(z * (x * y));
} else if ((y <= -1.25e+132) || (!(y <= -6.2e+75) && (y <= 1.8e-100))) {
tmp = x;
} else {
tmp = y * (z * -x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.5e+139: tmp = -(z * (x * y)) elif (y <= -1.25e+132) or (not (y <= -6.2e+75) and (y <= 1.8e-100)): tmp = x else: tmp = y * (z * -x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.5e+139) tmp = Float64(-Float64(z * Float64(x * y))); elseif ((y <= -1.25e+132) || (!(y <= -6.2e+75) && (y <= 1.8e-100))) tmp = x; else tmp = Float64(y * Float64(z * Float64(-x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.5e+139) tmp = -(z * (x * y)); elseif ((y <= -1.25e+132) || (~((y <= -6.2e+75)) && (y <= 1.8e-100))) tmp = x; else tmp = y * (z * -x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.5e+139], (-N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]), If[Or[LessEqual[y, -1.25e+132], And[N[Not[LessEqual[y, -6.2e+75]], $MachinePrecision], LessEqual[y, 1.8e-100]]], x, N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+139}:\\
\;\;\;\;-z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq -1.25 \cdot 10^{+132} \lor \neg \left(y \leq -6.2 \cdot 10^{+75}\right) \land y \leq 1.8 \cdot 10^{-100}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\end{array}
\end{array}
if y < -2.50000000000000015e139Initial program 93.1%
Taylor expanded in y around inf 88.5%
mul-1-neg88.5%
associate-*r*91.7%
Simplified91.7%
if -2.50000000000000015e139 < y < -1.25e132 or -6.2000000000000002e75 < y < 1.7999999999999999e-100Initial program 99.2%
Taylor expanded in y around 0 75.5%
if -1.25e132 < y < -6.2000000000000002e75 or 1.7999999999999999e-100 < y Initial program 95.3%
Taylor expanded in y around inf 63.1%
mul-1-neg63.1%
associate-*r*61.4%
distribute-rgt-neg-in61.4%
*-commutative61.4%
associate-*r*65.7%
distribute-rgt-neg-out65.7%
Simplified65.7%
Final simplification73.3%
(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.0%
Final simplification97.0%
(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.0%
Taylor expanded in y around 0 50.9%
Final simplification50.9%
herbie shell --seed 2023308
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))