
(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 2.0) y (* -0.125 z)))
double code(double x, double y, double z) {
return fma((x / 2.0), y, (-0.125 * z));
}
function code(x, y, z) return fma(Float64(x / 2.0), y, Float64(-0.125 * z)) end
code[x_, y_, z_] := N[(N[(x / 2.0), $MachinePrecision] * y + N[(-0.125 * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{2}, y, -0.125 \cdot z\right)
\end{array}
Initial program 100.0%
associate-*l/100.0%
fma-neg100.0%
distribute-frac-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (or (<= (* x y) -1.6e+25)
(not
(or (<= (* x y) -2.6e-44)
(and (not (<= (* x y) -2.1e-67)) (<= (* x y) 1.05e+63)))))
(* (* x y) 0.5)
(* -0.125 z)))
double code(double x, double y, double z) {
double tmp;
if (((x * y) <= -1.6e+25) || !(((x * y) <= -2.6e-44) || (!((x * y) <= -2.1e-67) && ((x * y) <= 1.05e+63)))) {
tmp = (x * y) * 0.5;
} else {
tmp = -0.125 * 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) :: tmp
if (((x * y) <= (-1.6d+25)) .or. (.not. ((x * y) <= (-2.6d-44)) .or. (.not. ((x * y) <= (-2.1d-67))) .and. ((x * y) <= 1.05d+63))) then
tmp = (x * y) * 0.5d0
else
tmp = (-0.125d0) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((x * y) <= -1.6e+25) || !(((x * y) <= -2.6e-44) || (!((x * y) <= -2.1e-67) && ((x * y) <= 1.05e+63)))) {
tmp = (x * y) * 0.5;
} else {
tmp = -0.125 * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x * y) <= -1.6e+25) or not (((x * y) <= -2.6e-44) or (not ((x * y) <= -2.1e-67) and ((x * y) <= 1.05e+63))): tmp = (x * y) * 0.5 else: tmp = -0.125 * z return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(x * y) <= -1.6e+25) || !((Float64(x * y) <= -2.6e-44) || (!(Float64(x * y) <= -2.1e-67) && (Float64(x * y) <= 1.05e+63)))) tmp = Float64(Float64(x * y) * 0.5); else tmp = Float64(-0.125 * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((x * y) <= -1.6e+25) || ~((((x * y) <= -2.6e-44) || (~(((x * y) <= -2.1e-67)) && ((x * y) <= 1.05e+63))))) tmp = (x * y) * 0.5; else tmp = -0.125 * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -1.6e+25], N[Not[Or[LessEqual[N[(x * y), $MachinePrecision], -2.6e-44], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], -2.1e-67]], $MachinePrecision], LessEqual[N[(x * y), $MachinePrecision], 1.05e+63]]]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] * 0.5), $MachinePrecision], N[(-0.125 * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.6 \cdot 10^{+25} \lor \neg \left(x \cdot y \leq -2.6 \cdot 10^{-44} \lor \neg \left(x \cdot y \leq -2.1 \cdot 10^{-67}\right) \land x \cdot y \leq 1.05 \cdot 10^{+63}\right):\\
\;\;\;\;\left(x \cdot y\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot z\\
\end{array}
\end{array}
if (*.f64 x y) < -1.6e25 or -2.5999999999999998e-44 < (*.f64 x y) < -2.1000000000000002e-67 or 1.0500000000000001e63 < (*.f64 x y) Initial program 100.0%
associate-*l/100.0%
fma-neg100.0%
distribute-frac-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
Simplified100.0%
*-commutative100.0%
metadata-eval100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
div-inv100.0%
fma-neg100.0%
associate-/r/99.8%
associate-/l*100.0%
frac-2neg100.0%
clear-num99.9%
frac-sub85.5%
metadata-eval85.5%
metadata-eval85.5%
metadata-eval85.5%
div-sub85.5%
Applied egg-rr81.5%
associate-*r*85.5%
div-inv85.5%
associate-*r*84.9%
div-inv84.9%
times-frac99.3%
associate-*r*99.3%
neg-mul-199.3%
*-commutative99.3%
associate-*l*99.3%
metadata-eval99.3%
Applied egg-rr99.3%
*-inverses99.3%
*-rgt-identity99.3%
associate-/l*99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 82.3%
if -1.6e25 < (*.f64 x y) < -2.5999999999999998e-44 or -2.1000000000000002e-67 < (*.f64 x y) < 1.0500000000000001e63Initial program 100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.8%
Final simplification80.0%
(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 (* -0.125 z))
double code(double x, double y, double z) {
return -0.125 * z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-0.125d0) * z
end function
public static double code(double x, double y, double z) {
return -0.125 * z;
}
def code(x, y, z): return -0.125 * z
function code(x, y, z) return Float64(-0.125 * z) end
function tmp = code(x, y, z) tmp = -0.125 * z; end
code[x_, y_, z_] := N[(-0.125 * z), $MachinePrecision]
\begin{array}{l}
\\
-0.125 \cdot z
\end{array}
Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 49.2%
Final simplification49.2%
herbie shell --seed 2023297
(FPCore (x y z)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, D"
:precision binary64
(- (/ (* x y) 2.0) (/ z 8.0)))