
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.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) / ((z * z) * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z): return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z) return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) end
function tmp = code(x, y, z) tmp = (x * y) / ((z * z) * (z + 1.0)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.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) / ((z * z) * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z): return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z) return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) end
function tmp = code(x, y, z) tmp = (x * y) / ((z * z) * (z + 1.0)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= (* x y) 5e-64) (/ (* (/ (/ x z) (+ z 1.0)) y) z) (/ (/ x (+ z 1.0)) (* (/ z y) z))))
double code(double x, double y, double z) {
double tmp;
if ((x * y) <= 5e-64) {
tmp = (((x / z) / (z + 1.0)) * y) / z;
} else {
tmp = (x / (z + 1.0)) / ((z / y) * 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) <= 5d-64) then
tmp = (((x / z) / (z + 1.0d0)) * y) / z
else
tmp = (x / (z + 1.0d0)) / ((z / y) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * y) <= 5e-64) {
tmp = (((x / z) / (z + 1.0)) * y) / z;
} else {
tmp = (x / (z + 1.0)) / ((z / y) * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * y) <= 5e-64: tmp = (((x / z) / (z + 1.0)) * y) / z else: tmp = (x / (z + 1.0)) / ((z / y) * z) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * y) <= 5e-64) tmp = Float64(Float64(Float64(Float64(x / z) / Float64(z + 1.0)) * y) / z); else tmp = Float64(Float64(x / Float64(z + 1.0)) / Float64(Float64(z / y) * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * y) <= 5e-64) tmp = (((x / z) / (z + 1.0)) * y) / z; else tmp = (x / (z + 1.0)) / ((z / y) * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * y), $MachinePrecision], 5e-64], N[(N[(N[(N[(x / z), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(z / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 5 \cdot 10^{-64}:\\
\;\;\;\;\frac{\frac{\frac{x}{z}}{z + 1} \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z + 1}}{\frac{z}{y} \cdot z}\\
\end{array}
\end{array}
if (*.f64 x y) < 5.00000000000000033e-64Initial program 81.9%
Applied egg-rr0
Applied egg-rr0
if 5.00000000000000033e-64 < (*.f64 x y) Initial program 88.2%
Applied egg-rr0
Applied egg-rr0
(FPCore (x y z) :precision binary64 (/ (/ (/ y z) (/ (+ z 1.0) x)) z))
double code(double x, double y, double z) {
return ((y / z) / ((z + 1.0) / x)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y / z) / ((z + 1.0d0) / x)) / z
end function
public static double code(double x, double y, double z) {
return ((y / z) / ((z + 1.0) / x)) / z;
}
def code(x, y, z): return ((y / z) / ((z + 1.0) / x)) / z
function code(x, y, z) return Float64(Float64(Float64(y / z) / Float64(Float64(z + 1.0) / x)) / z) end
function tmp = code(x, y, z) tmp = ((y / z) / ((z + 1.0) / x)) / z; end
code[x_, y_, z_] := N[(N[(N[(y / z), $MachinePrecision] / N[(N[(z + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{y}{z}}{\frac{z + 1}{x}}}{z}
\end{array}
Initial program 83.9%
Applied egg-rr0
Applied egg-rr0
(FPCore (x y z) :precision binary64 (/ (/ (* x (/ y z)) (+ z 1.0)) z))
double code(double x, double y, double z) {
return ((x * (y / z)) / (z + 1.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 / z)) / (z + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return ((x * (y / z)) / (z + 1.0)) / z;
}
def code(x, y, z): return ((x * (y / z)) / (z + 1.0)) / z
function code(x, y, z) return Float64(Float64(Float64(x * Float64(y / z)) / Float64(z + 1.0)) / z) end
function tmp = code(x, y, z) tmp = ((x * (y / z)) / (z + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x \cdot \frac{y}{z}}{z + 1}}{z}
\end{array}
Initial program 83.9%
Applied egg-rr0
Applied egg-rr0
(FPCore (x y z) :precision binary64 (/ (* (/ y (+ z 1.0)) (/ x z)) z))
double code(double x, double y, double z) {
return ((y / (z + 1.0)) * (x / z)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y / (z + 1.0d0)) * (x / z)) / z
end function
public static double code(double x, double y, double z) {
return ((y / (z + 1.0)) * (x / z)) / z;
}
def code(x, y, z): return ((y / (z + 1.0)) * (x / z)) / z
function code(x, y, z) return Float64(Float64(Float64(y / Float64(z + 1.0)) * Float64(x / z)) / z) end
function tmp = code(x, y, z) tmp = ((y / (z + 1.0)) * (x / z)) / z; end
code[x_, y_, z_] := N[(N[(N[(y / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{z + 1} \cdot \frac{x}{z}}{z}
\end{array}
Initial program 83.9%
Applied egg-rr0
(FPCore (x y z) :precision binary64 (/ (* (/ y z) x) (* z (+ z 1.0))))
double code(double x, double y, double z) {
return ((y / z) * x) / (z * (z + 1.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y / z) * x) / (z * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
return ((y / z) * x) / (z * (z + 1.0));
}
def code(x, y, z): return ((y / z) * x) / (z * (z + 1.0))
function code(x, y, z) return Float64(Float64(Float64(y / z) * x) / Float64(z * Float64(z + 1.0))) end
function tmp = code(x, y, z) tmp = ((y / z) * x) / (z * (z + 1.0)); end
code[x_, y_, z_] := N[(N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision] / N[(z * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{z} \cdot x}{z \cdot \left(z + 1\right)}
\end{array}
Initial program 83.9%
Applied egg-rr0
(FPCore (x y z) :precision binary64 (/ (* x (/ y (* z (+ z 1.0)))) z))
double code(double x, double y, double z) {
return (x * (y / (z * (z + 1.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 / (z * (z + 1.0d0)))) / z
end function
public static double code(double x, double y, double z) {
return (x * (y / (z * (z + 1.0)))) / z;
}
def code(x, y, z): return (x * (y / (z * (z + 1.0)))) / z
function code(x, y, z) return Float64(Float64(x * Float64(y / Float64(z * Float64(z + 1.0)))) / z) end
function tmp = code(x, y, z) tmp = (x * (y / (z * (z + 1.0)))) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y / N[(z * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{y}{z \cdot \left(z + 1\right)}}{z}
\end{array}
Initial program 83.9%
Applied egg-rr0
(FPCore (x y z) :precision binary64 (* (/ y (* z (+ z 1.0))) (/ x z)))
double code(double x, double y, double z) {
return (y / (z * (z + 1.0))) * (x / z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y / (z * (z + 1.0d0))) * (x / z)
end function
public static double code(double x, double y, double z) {
return (y / (z * (z + 1.0))) * (x / z);
}
def code(x, y, z): return (y / (z * (z + 1.0))) * (x / z)
function code(x, y, z) return Float64(Float64(y / Float64(z * Float64(z + 1.0))) * Float64(x / z)) end
function tmp = code(x, y, z) tmp = (y / (z * (z + 1.0))) * (x / z); end
code[x_, y_, z_] := N[(N[(y / N[(z * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{z \cdot \left(z + 1\right)} \cdot \frac{x}{z}
\end{array}
Initial program 83.9%
Applied egg-rr0
(FPCore (x y z) :precision binary64 (if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z)))
double code(double x, double y, double z) {
double tmp;
if (z < 249.6182814532307) {
tmp = (y * (x / z)) / (z + (z * z));
} else {
tmp = (((y / z) / (1.0 + z)) * x) / 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 (z < 249.6182814532307d0) then
tmp = (y * (x / z)) / (z + (z * z))
else
tmp = (((y / z) / (1.0d0 + z)) * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < 249.6182814532307) {
tmp = (y * (x / z)) / (z + (z * z));
} else {
tmp = (((y / z) / (1.0 + z)) * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < 249.6182814532307: tmp = (y * (x / z)) / (z + (z * z)) else: tmp = (((y / z) / (1.0 + z)) * x) / z return tmp
function code(x, y, z) tmp = 0.0 if (z < 249.6182814532307) tmp = Float64(Float64(y * Float64(x / z)) / Float64(z + Float64(z * z))); else tmp = Float64(Float64(Float64(Float64(y / z) / Float64(1.0 + z)) * x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < 249.6182814532307) tmp = (y * (x / z)) / (z + (z * z)); else tmp = (((y / z) / (1.0 + z)) * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, 249.6182814532307], N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] / N[(z + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / z), $MachinePrecision] / N[(1.0 + z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z < 249.6182814532307:\\
\;\;\;\;\frac{y \cdot \frac{x}{z}}{z + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{y}{z}}{1 + z} \cdot x}{z}\\
\end{array}
\end{array}
herbie shell --seed 2024107
(FPCore (x y z)
:name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
:precision binary64
:alt
(if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z))
(/ (* x y) (* (* z z) (+ z 1.0))))