
(FPCore (x y z) :precision binary64 (- x (* (* y 4.0) z)))
double code(double x, double y, double z) {
return x - ((y * 4.0) * 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 * 4.0d0) * z)
end function
public static double code(double x, double y, double z) {
return x - ((y * 4.0) * z);
}
def code(x, y, z): return x - ((y * 4.0) * z)
function code(x, y, z) return Float64(x - Float64(Float64(y * 4.0) * z)) end
function tmp = code(x, y, z) tmp = x - ((y * 4.0) * z); end
code[x_, y_, z_] := N[(x - N[(N[(y * 4.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(y \cdot 4\right) \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- x (* (* y 4.0) z)))
double code(double x, double y, double z) {
return x - ((y * 4.0) * 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 * 4.0d0) * z)
end function
public static double code(double x, double y, double z) {
return x - ((y * 4.0) * z);
}
def code(x, y, z): return x - ((y * 4.0) * z)
function code(x, y, z) return Float64(x - Float64(Float64(y * 4.0) * z)) end
function tmp = code(x, y, z) tmp = x - ((y * 4.0) * z); end
code[x_, y_, z_] := N[(x - N[(N[(y * 4.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(y \cdot 4\right) \cdot z
\end{array}
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (- x (* y (* 4.0 z))))
assert(y < z);
double code(double x, double y, double z) {
return x - (y * (4.0 * z));
}
NOTE: y and z should be sorted in increasing order before calling this function.
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 * (4.0d0 * z))
end function
assert y < z;
public static double code(double x, double y, double z) {
return x - (y * (4.0 * z));
}
[y, z] = sort([y, z]) def code(x, y, z): return x - (y * (4.0 * z))
y, z = sort([y, z]) function code(x, y, z) return Float64(x - Float64(y * Float64(4.0 * z))) end
y, z = num2cell(sort([y, z])){:}
function tmp = code(x, y, z)
tmp = x - (y * (4.0 * z));
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(x - N[(y * N[(4.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
x - y \cdot \left(4 \cdot z\right)
\end{array}
Initial program 99.6%
associate-*l*99.6%
Simplified99.6%
Final simplification99.6%
NOTE: y and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (or (<= z -4.4e-60)
(and (not (<= z 4.2e+43)) (or (<= z 6.4e+84) (not (<= z 2.2e+123)))))
(* y (* z -4.0))
x))assert(y < z);
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.4e-60) || (!(z <= 4.2e+43) && ((z <= 6.4e+84) || !(z <= 2.2e+123)))) {
tmp = y * (z * -4.0);
} else {
tmp = x;
}
return tmp;
}
NOTE: y and z should be sorted in increasing order before calling this function.
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.4d-60)) .or. (.not. (z <= 4.2d+43)) .and. (z <= 6.4d+84) .or. (.not. (z <= 2.2d+123))) then
tmp = y * (z * (-4.0d0))
else
tmp = x
end if
code = tmp
end function
assert y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.4e-60) || (!(z <= 4.2e+43) && ((z <= 6.4e+84) || !(z <= 2.2e+123)))) {
tmp = y * (z * -4.0);
} else {
tmp = x;
}
return tmp;
}
[y, z] = sort([y, z]) def code(x, y, z): tmp = 0 if (z <= -4.4e-60) or (not (z <= 4.2e+43) and ((z <= 6.4e+84) or not (z <= 2.2e+123))): tmp = y * (z * -4.0) else: tmp = x return tmp
y, z = sort([y, z]) function code(x, y, z) tmp = 0.0 if ((z <= -4.4e-60) || (!(z <= 4.2e+43) && ((z <= 6.4e+84) || !(z <= 2.2e+123)))) tmp = Float64(y * Float64(z * -4.0)); else tmp = x; end return tmp end
y, z = num2cell(sort([y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z <= -4.4e-60) || (~((z <= 4.2e+43)) && ((z <= 6.4e+84) || ~((z <= 2.2e+123)))))
tmp = y * (z * -4.0);
else
tmp = x;
end
tmp_2 = tmp;
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[Or[LessEqual[z, -4.4e-60], And[N[Not[LessEqual[z, 4.2e+43]], $MachinePrecision], Or[LessEqual[z, 6.4e+84], N[Not[LessEqual[z, 2.2e+123]], $MachinePrecision]]]], N[(y * N[(z * -4.0), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{-60} \lor \neg \left(z \leq 4.2 \cdot 10^{+43}\right) \land \left(z \leq 6.4 \cdot 10^{+84} \lor \neg \left(z \leq 2.2 \cdot 10^{+123}\right)\right):\\
\;\;\;\;y \cdot \left(z \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.3999999999999998e-60 or 4.20000000000000003e43 < z < 6.4000000000000002e84 or 2.19999999999999992e123 < z Initial program 100.0%
associate-*l*99.2%
Simplified99.2%
Taylor expanded in x around 0 72.4%
associate-*r*72.4%
*-commutative72.4%
associate-*r*71.5%
Simplified71.5%
if -4.3999999999999998e-60 < z < 4.20000000000000003e43 or 6.4000000000000002e84 < z < 2.19999999999999992e123Initial program 99.3%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around inf 73.9%
Final simplification72.8%
NOTE: y and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 x)
assert(y < z);
double code(double x, double y, double z) {
return x;
}
NOTE: y and z should be sorted in increasing order before calling this function.
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
assert y < z;
public static double code(double x, double y, double z) {
return x;
}
[y, z] = sort([y, z]) def code(x, y, z): return x
y, z = sort([y, z]) function code(x, y, z) return x end
y, z = num2cell(sort([y, z])){:}
function tmp = code(x, y, z)
tmp = x;
end
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := x
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
x
\end{array}
Initial program 99.6%
associate-*l*99.6%
Simplified99.6%
Taylor expanded in x around inf 53.4%
Final simplification53.4%
herbie shell --seed 2023279
(FPCore (x y z)
:name "Diagrams.Solve.Polynomial:quadForm from diagrams-solve-0.1, A"
:precision binary64
(- x (* (* y 4.0) z)))