
(FPCore (x y z) :precision binary64 (- (/ (* x y) 2.0) (/ z 8.0)))
double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.0);
}
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) / 2.0d0) - (z / 8.0d0)
end function
public static double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.0);
}
def code(x, y, z): return ((x * y) / 2.0) - (z / 8.0)
function code(x, y, z) return Float64(Float64(Float64(x * y) / 2.0) - Float64(z / 8.0)) end
function tmp = code(x, y, z) tmp = ((x * y) / 2.0) - (z / 8.0); end
code[x_, y_, z_] := N[(N[(N[(x * y), $MachinePrecision] / 2.0), $MachinePrecision] - N[(z / 8.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{2} - \frac{z}{8}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (/ (* x y) 2.0) (/ z 8.0)))
double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.0);
}
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) / 2.0d0) - (z / 8.0d0)
end function
public static double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.0);
}
def code(x, y, z): return ((x * y) / 2.0) - (z / 8.0)
function code(x, y, z) return Float64(Float64(Float64(x * y) / 2.0) - Float64(z / 8.0)) end
function tmp = code(x, y, z) tmp = ((x * y) / 2.0) - (z / 8.0); end
code[x_, y_, z_] := N[(N[(N[(x * y), $MachinePrecision] / 2.0), $MachinePrecision] - N[(z / 8.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{2} - \frac{z}{8}
\end{array}
(FPCore (x y z) :precision binary64 (fma x (/ y 2.0) (* z -0.125)))
double code(double x, double y, double z) {
return fma(x, (y / 2.0), (z * -0.125));
}
function code(x, y, z) return fma(x, Float64(y / 2.0), Float64(z * -0.125)) end
code[x_, y_, z_] := N[(x * N[(y / 2.0), $MachinePrecision] + N[(z * -0.125), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \frac{y}{2}, z \cdot -0.125\right)
\end{array}
Initial program 100.0%
associate-*r/100.0%
*-commutative100.0%
*-commutative100.0%
fma-neg100.0%
distribute-neg-frac100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
*-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (or (<= y -5.8e-63)
(not
(or (<= y 90000000000000.0)
(and (not (<= y 8.4e+57)) (<= y 8e+108)))))
(* 0.5 (* x y))
(* z -0.125)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.8e-63) || !((y <= 90000000000000.0) || (!(y <= 8.4e+57) && (y <= 8e+108)))) {
tmp = 0.5 * (x * y);
} else {
tmp = z * -0.125;
}
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 <= (-5.8d-63)) .or. (.not. (y <= 90000000000000.0d0) .or. (.not. (y <= 8.4d+57)) .and. (y <= 8d+108))) then
tmp = 0.5d0 * (x * y)
else
tmp = z * (-0.125d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.8e-63) || !((y <= 90000000000000.0) || (!(y <= 8.4e+57) && (y <= 8e+108)))) {
tmp = 0.5 * (x * y);
} else {
tmp = z * -0.125;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.8e-63) or not ((y <= 90000000000000.0) or (not (y <= 8.4e+57) and (y <= 8e+108))): tmp = 0.5 * (x * y) else: tmp = z * -0.125 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.8e-63) || !((y <= 90000000000000.0) || (!(y <= 8.4e+57) && (y <= 8e+108)))) tmp = Float64(0.5 * Float64(x * y)); else tmp = Float64(z * -0.125); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.8e-63) || ~(((y <= 90000000000000.0) || (~((y <= 8.4e+57)) && (y <= 8e+108))))) tmp = 0.5 * (x * y); else tmp = z * -0.125; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.8e-63], N[Not[Or[LessEqual[y, 90000000000000.0], And[N[Not[LessEqual[y, 8.4e+57]], $MachinePrecision], LessEqual[y, 8e+108]]]], $MachinePrecision]], N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(z * -0.125), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{-63} \lor \neg \left(y \leq 90000000000000 \lor \neg \left(y \leq 8.4 \cdot 10^{+57}\right) \land y \leq 8 \cdot 10^{+108}\right):\\
\;\;\;\;0.5 \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot -0.125\\
\end{array}
\end{array}
if y < -5.7999999999999995e-63 or 9e13 < y < 8.39999999999999964e57 or 8.0000000000000003e108 < y Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
associate-/l*100.0%
frac-2neg100.0%
clear-num99.9%
frac-sub87.0%
metadata-eval87.0%
metadata-eval87.0%
metadata-eval87.0%
fma-neg87.0%
distribute-rgt-neg-in87.0%
metadata-eval87.0%
metadata-eval87.0%
metadata-eval87.0%
Applied egg-rr87.0%
associate-*r/87.0%
metadata-eval87.0%
associate-/r/87.9%
Simplified88.0%
Taylor expanded in y around inf 73.4%
if -5.7999999999999995e-63 < y < 9e13 or 8.39999999999999964e57 < y < 8.0000000000000003e108Initial program 100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 75.1%
Final simplification74.2%
(FPCore (x y z) :precision binary64 (- (/ x (/ 2.0 y)) (/ z 8.0)))
double code(double x, double y, double z) {
return (x / (2.0 / y)) - (z / 8.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / (2.0d0 / y)) - (z / 8.0d0)
end function
public static double code(double x, double y, double z) {
return (x / (2.0 / y)) - (z / 8.0);
}
def code(x, y, z): return (x / (2.0 / y)) - (z / 8.0)
function code(x, y, z) return Float64(Float64(x / Float64(2.0 / y)) - Float64(z / 8.0)) end
function tmp = code(x, y, z) tmp = (x / (2.0 / y)) - (z / 8.0); end
code[x_, y_, z_] := N[(N[(x / N[(2.0 / y), $MachinePrecision]), $MachinePrecision] - N[(z / 8.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{2}{y}} - \frac{z}{8}
\end{array}
Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (- (/ (* x y) 2.0) (/ z 8.0)))
double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.0);
}
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) / 2.0d0) - (z / 8.0d0)
end function
public static double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.0);
}
def code(x, y, z): return ((x * y) / 2.0) - (z / 8.0)
function code(x, y, z) return Float64(Float64(Float64(x * y) / 2.0) - Float64(z / 8.0)) end
function tmp = code(x, y, z) tmp = ((x * y) / 2.0) - (z / 8.0); end
code[x_, y_, z_] := N[(N[(N[(x * y), $MachinePrecision] / 2.0), $MachinePrecision] - N[(z / 8.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{2} - \frac{z}{8}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (* z -0.125))
double code(double x, double y, double z) {
return z * -0.125;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z * (-0.125d0)
end function
public static double code(double x, double y, double z) {
return z * -0.125;
}
def code(x, y, z): return z * -0.125
function code(x, y, z) return Float64(z * -0.125) end
function tmp = code(x, y, z) tmp = z * -0.125; end
code[x_, y_, z_] := N[(z * -0.125), $MachinePrecision]
\begin{array}{l}
\\
z \cdot -0.125
\end{array}
Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 52.1%
Final simplification52.1%
herbie shell --seed 2023182
(FPCore (x y z)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, D"
:precision binary64
(- (/ (* x y) 2.0) (/ z 8.0)))