
(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 14 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}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ (* (/ x z) y) (+ 1.0 z)) z))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (((x / z) * y) / (1.0 + z)) / z;
}
NOTE: x, 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 / z) * y) / (1.0d0 + z)) / z
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return (((x / z) * y) / (1.0 + z)) / z;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return (((x / z) * y) / (1.0 + z)) / z
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(Float64(Float64(x / z) * y) / Float64(1.0 + z)) / z) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (((x / z) * y) / (1.0 + z)) / z;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{\frac{\frac{x}{z} \cdot y}{1 + z}}{z}
\end{array}
Initial program 89.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
Final simplification98.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (let* ((t_0 (* (* z z) (+ 1.0 z))) (t_1 (* (/ y (* (fma z z z) z)) x))) (if (<= t_0 -1e+21) t_1 (if (<= t_0 2e-37) (/ (* (/ x z) y) z) t_1))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = (z * z) * (1.0 + z);
double t_1 = (y / (fma(z, z, z) * z)) * x;
double tmp;
if (t_0 <= -1e+21) {
tmp = t_1;
} else if (t_0 <= 2e-37) {
tmp = ((x / z) * y) / z;
} else {
tmp = t_1;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(Float64(z * z) * Float64(1.0 + z)) t_1 = Float64(Float64(y / Float64(fma(z, z, z) * z)) * x) tmp = 0.0 if (t_0 <= -1e+21) tmp = t_1; elseif (t_0 <= 2e-37) tmp = Float64(Float64(Float64(x / z) * y) / z); else tmp = t_1; end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * z), $MachinePrecision] * N[(1.0 + z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+21], t$95$1, If[LessEqual[t$95$0, 2e-37], N[(N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision] / z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \left(z \cdot z\right) \cdot \left(1 + z\right)\\
t_1 := \frac{y}{\mathsf{fma}\left(z, z, z\right) \cdot z} \cdot x\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-37}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) < -1e21 or 2.00000000000000013e-37 < (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) Initial program 89.3%
Taylor expanded in z around 0
unpow2N/A
lower-*.f6455.6
Applied rewrites55.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6461.6
Applied rewrites61.6%
Taylor expanded in z around 0
distribute-lft-inN/A
*-rgt-identityN/A
unpow2N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f6489.1
Applied rewrites89.1%
if -1e21 < (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) < 2.00000000000000013e-37Initial program 90.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.8
Applied rewrites98.8%
Taylor expanded in z around 0
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6494.6
Applied rewrites94.6%
Applied rewrites98.8%
Final simplification94.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* x y) 1e-187) (/ (/ y z) (/ z x)) (/ (* x y) (* (* z z) (+ 1.0 z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((x * y) <= 1e-187) {
tmp = (y / z) / (z / x);
} else {
tmp = (x * y) / ((z * z) * (1.0 + z));
}
return tmp;
}
NOTE: x, 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 ((x * y) <= 1d-187) then
tmp = (y / z) / (z / x)
else
tmp = (x * y) / ((z * z) * (1.0d0 + z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((x * y) <= 1e-187) {
tmp = (y / z) / (z / x);
} else {
tmp = (x * y) / ((z * z) * (1.0 + z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (x * y) <= 1e-187: tmp = (y / z) / (z / x) else: tmp = (x * y) / ((z * z) * (1.0 + z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(x * y) <= 1e-187) tmp = Float64(Float64(y / z) / Float64(z / x)); else tmp = Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(1.0 + z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((x * y) <= 1e-187)
tmp = (y / z) / (z / x);
else
tmp = (x * y) / ((z * z) * (1.0 + z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(x * y), $MachinePrecision], 1e-187], N[(N[(y / z), $MachinePrecision] / N[(z / x), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 10^{-187}:\\
\;\;\;\;\frac{\frac{y}{z}}{\frac{z}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(1 + z\right)}\\
\end{array}
\end{array}
if (*.f64 x y) < 1e-187Initial program 88.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.5
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.5
Applied rewrites98.5%
Taylor expanded in z around 0
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6474.0
Applied rewrites74.0%
Applied rewrites80.3%
if 1e-187 < (*.f64 x y) Initial program 92.0%
Final simplification84.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ y (+ 1.0 z)) (* (/ z x) z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (y / (1.0 + z)) / ((z / x) * z);
}
NOTE: x, 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 = (y / (1.0d0 + z)) / ((z / x) * z)
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return (y / (1.0 + z)) / ((z / x) * z);
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return (y / (1.0 + z)) / ((z / x) * z)
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(y / Float64(1.0 + z)) / Float64(Float64(z / x) * z)) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (y / (1.0 + z)) / ((z / x) * z);
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(y / N[(1.0 + z), $MachinePrecision]), $MachinePrecision] / N[(N[(z / x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{\frac{y}{1 + z}}{\frac{z}{x} \cdot z}
\end{array}
Initial program 89.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6496.8
Applied rewrites96.8%
Final simplification96.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (/ (/ x z) z) (/ y (+ 1.0 z))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return ((x / z) / z) * (y / (1.0 + z));
}
NOTE: x, 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 / z) / z) * (y / (1.0d0 + z))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return ((x / z) / z) * (y / (1.0 + z));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return ((x / z) / z) * (y / (1.0 + z))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(Float64(x / z) / z) * Float64(y / Float64(1.0 + z))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = ((x / z) / z) * (y / (1.0 + z));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[(x / z), $MachinePrecision] / z), $MachinePrecision] * N[(y / N[(1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{\frac{x}{z}}{z} \cdot \frac{y}{1 + z}
\end{array}
Initial program 89.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6495.9
Applied rewrites95.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* x y) 1e-187) (* (/ y z) (/ x z)) (/ (* x y) (* (* z z) (+ 1.0 z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((x * y) <= 1e-187) {
tmp = (y / z) * (x / z);
} else {
tmp = (x * y) / ((z * z) * (1.0 + z));
}
return tmp;
}
NOTE: x, 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 ((x * y) <= 1d-187) then
tmp = (y / z) * (x / z)
else
tmp = (x * y) / ((z * z) * (1.0d0 + z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if ((x * y) <= 1e-187) {
tmp = (y / z) * (x / z);
} else {
tmp = (x * y) / ((z * z) * (1.0 + z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if (x * y) <= 1e-187: tmp = (y / z) * (x / z) else: tmp = (x * y) / ((z * z) * (1.0 + z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(x * y) <= 1e-187) tmp = Float64(Float64(y / z) * Float64(x / z)); else tmp = Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(1.0 + z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((x * y) <= 1e-187)
tmp = (y / z) * (x / z);
else
tmp = (x * y) / ((z * z) * (1.0 + z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(x * y), $MachinePrecision], 1e-187], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 10^{-187}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(1 + z\right)}\\
\end{array}
\end{array}
if (*.f64 x y) < 1e-187Initial program 88.3%
Taylor expanded in z around 0
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6480.3
Applied rewrites80.3%
if 1e-187 < (*.f64 x y) Initial program 92.0%
Final simplification84.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ x z) (/ (fma z z z) y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (x / z) / (fma(z, z, z) / y);
}
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(x / z) / Float64(fma(z, z, z) / y)) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] / N[(N[(z * z + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{\frac{x}{z}}{\frac{\mathsf{fma}\left(z, z, z\right)}{y}}
\end{array}
Initial program 89.7%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
times-fracN/A
associate-/r*N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6495.7
Applied rewrites95.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* x y) 1e-187) (* (/ y z) (/ x z)) (/ (* x y) (* (fma z z z) z))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((x * y) <= 1e-187) {
tmp = (y / z) * (x / z);
} else {
tmp = (x * y) / (fma(z, z, z) * z);
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(x * y) <= 1e-187) tmp = Float64(Float64(y / z) * Float64(x / z)); else tmp = Float64(Float64(x * y) / Float64(fma(z, z, z) * z)); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(x * y), $MachinePrecision], 1e-187], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 10^{-187}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(z, z, z\right) \cdot z}\\
\end{array}
\end{array}
if (*.f64 x y) < 1e-187Initial program 88.3%
Taylor expanded in z around 0
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6480.3
Applied rewrites80.3%
if 1e-187 < (*.f64 x y) Initial program 92.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6492.0
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6492.0
Applied rewrites92.0%
Final simplification84.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* x y) 1e-187) (* (/ y z) (/ x z)) (* (/ x (* (fma z z z) z)) y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if ((x * y) <= 1e-187) {
tmp = (y / z) * (x / z);
} else {
tmp = (x / (fma(z, z, z) * z)) * y;
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (Float64(x * y) <= 1e-187) tmp = Float64(Float64(y / z) * Float64(x / z)); else tmp = Float64(Float64(x / Float64(fma(z, z, z) * z)) * y); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(x * y), $MachinePrecision], 1e-187], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 10^{-187}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(z, z, z\right) \cdot z} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < 1e-187Initial program 88.3%
Taylor expanded in z around 0
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6480.3
Applied rewrites80.3%
if 1e-187 < (*.f64 x y) Initial program 92.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.8
Applied rewrites98.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6493.8
Applied rewrites93.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
remove-double-negN/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites89.6%
Final simplification83.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 2e+26) (* (/ y z) (/ x z)) (* (/ x (* z z)) y)))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 2e+26) {
tmp = (y / z) * (x / z);
} else {
tmp = (x / (z * z)) * y;
}
return tmp;
}
NOTE: x, 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 (y <= 2d+26) then
tmp = (y / z) * (x / z)
else
tmp = (x / (z * z)) * y
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2e+26) {
tmp = (y / z) * (x / z);
} else {
tmp = (x / (z * z)) * y;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 2e+26: tmp = (y / z) * (x / z) else: tmp = (x / (z * z)) * y return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 2e+26) tmp = Float64(Float64(y / z) * Float64(x / z)); else tmp = Float64(Float64(x / Float64(z * z)) * y); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 2e+26)
tmp = (y / z) * (x / z);
else
tmp = (x / (z * z)) * y;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 2e+26], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(z * z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+26}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot z} \cdot y\\
\end{array}
\end{array}
if y < 2.0000000000000001e26Initial program 88.9%
Taylor expanded in z around 0
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
if 2.0000000000000001e26 < y Initial program 93.7%
Taylor expanded in z around 0
unpow2N/A
lower-*.f6478.3
Applied rewrites78.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
Final simplification78.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (* (/ x z) y) (fma z z z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return ((x / z) * y) / fma(z, z, z);
}
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(Float64(x / z) * y) / fma(z, z, z)) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision] / N[(z * z + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{\frac{x}{z} \cdot y}{\mathsf{fma}\left(z, z, z\right)}
\end{array}
Initial program 89.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/r*N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6496.8
Applied rewrites96.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (/ x (fma z z z)) (/ y z)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (x / fma(z, z, z)) * (y / z);
}
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(x / fma(z, z, z)) * Float64(y / z)) end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(x / N[(z * z + z), $MachinePrecision]), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{x}{\mathsf{fma}\left(z, z, z\right)} \cdot \frac{y}{z}
\end{array}
Initial program 89.7%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6496.3
Applied rewrites96.3%
Final simplification96.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (/ (/ x z) z) y))
assert(x < y && y < z);
double code(double x, double y, double z) {
return ((x / z) / z) * y;
}
NOTE: x, 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 / z) / z) * y
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return ((x / z) / z) * y;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return ((x / z) / z) * y
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(Float64(x / z) / z) * y) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = ((x / z) / z) * y;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[(x / z), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{\frac{x}{z}}{z} \cdot y
\end{array}
Initial program 89.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
Taylor expanded in z around 0
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6473.0
Applied rewrites73.0%
Applied rewrites74.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (/ x (* z z)) y))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (x / (z * z)) * y;
}
NOTE: x, 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 / (z * z)) * y
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return (x / (z * z)) * y;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return (x / (z * z)) * y
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(x / Float64(z * z)) * y) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (x / (z * z)) * y;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(x / N[(z * z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{x}{z \cdot z} \cdot y
\end{array}
Initial program 89.7%
Taylor expanded in z around 0
unpow2N/A
lower-*.f6473.6
Applied rewrites73.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.4
Applied rewrites75.4%
Final simplification75.4%
(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 2024332
(FPCore (x y z)
:name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (if (< z 2496182814532307/10000000000000) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1 z)) x) z)))
(/ (* x y) (* (* z z) (+ z 1.0))))