
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (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 = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (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 = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 8e+185) (/ (/ 1.0 y) (* x (+ 1.0 (* z z)))) (/ (/ (/ (/ 1.0 y) z) x) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 8e+185) {
tmp = (1.0 / y) / (x * (1.0 + (z * z)));
} else {
tmp = (((1.0 / y) / z) / x) / z;
}
return tmp;
}
NOTE: x and y 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 * z) <= 8d+185) then
tmp = (1.0d0 / y) / (x * (1.0d0 + (z * z)))
else
tmp = (((1.0d0 / y) / z) / x) / z
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 8e+185) {
tmp = (1.0 / y) / (x * (1.0 + (z * z)));
} else {
tmp = (((1.0 / y) / z) / x) / z;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 8e+185: tmp = (1.0 / y) / (x * (1.0 + (z * z))) else: tmp = (((1.0 / y) / z) / x) / z return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 8e+185) tmp = Float64(Float64(1.0 / y) / Float64(x * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(Float64(Float64(1.0 / y) / z) / x) / z); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 8e+185)
tmp = (1.0 / y) / (x * (1.0 + (z * z)));
else
tmp = (((1.0 / y) / z) / x) / z;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 8e+185], N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 8 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{y}}{x \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{y}}{z}}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 7.9999999999999998e185Initial program 99.0%
associate-/r*98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
fma-udef98.4%
+-commutative98.4%
associate-/r*99.0%
associate-/r*98.4%
add-sqr-sqrt98.4%
*-un-lft-identity98.4%
times-frac98.4%
hypot-1-def98.4%
associate-/l/98.3%
hypot-1-def98.3%
Applied egg-rr98.3%
frac-times98.4%
*-un-lft-identity98.4%
associate-/r*98.5%
associate-/l/99.7%
hypot-udef99.7%
hypot-udef99.7%
add-sqr-sqrt99.7%
metadata-eval99.7%
Applied egg-rr99.7%
if 7.9999999999999998e185 < (*.f64 z z) Initial program 74.6%
associate-/r*74.6%
+-commutative74.6%
fma-def74.6%
Simplified74.6%
Taylor expanded in z around inf 74.4%
associate-/r*74.5%
*-un-lft-identity74.5%
pow274.5%
times-frac75.0%
associate-/r*75.0%
Applied egg-rr75.0%
associate-*l/75.0%
*-un-lft-identity75.0%
associate-/r*87.3%
associate-/r*87.2%
associate-/r*98.8%
*-commutative98.8%
associate-/r*96.6%
Applied egg-rr96.6%
Final simplification98.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (* (/ 1.0 x) (/ (/ 1.0 y) (hypot 1.0 z))) (hypot 1.0 z)))
assert(x < y);
double code(double x, double y, double z) {
return ((1.0 / x) * ((1.0 / y) / hypot(1.0, z))) / hypot(1.0, z);
}
assert x < y;
public static double code(double x, double y, double z) {
return ((1.0 / x) * ((1.0 / y) / Math.hypot(1.0, z))) / Math.hypot(1.0, z);
}
[x, y] = sort([x, y]) def code(x, y, z): return ((1.0 / x) * ((1.0 / y) / math.hypot(1.0, z))) / math.hypot(1.0, z)
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(Float64(1.0 / x) * Float64(Float64(1.0 / y) / hypot(1.0, z))) / hypot(1.0, z)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = ((1.0 / x) * ((1.0 / y) / hypot(1.0, z))) / hypot(1.0, z);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[(1.0 / x), $MachinePrecision] * N[(N[(1.0 / y), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{x} \cdot \frac{\frac{1}{y}}{\mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right)}
\end{array}
Initial program 89.5%
associate-/r*89.1%
+-commutative89.1%
fma-def89.1%
Simplified89.1%
fma-udef89.1%
+-commutative89.1%
associate-/r*89.5%
associate-/r*89.3%
add-sqr-sqrt89.3%
*-un-lft-identity89.3%
times-frac89.3%
hypot-1-def89.3%
associate-/l/89.2%
hypot-1-def94.0%
Applied egg-rr94.0%
associate-*l/94.0%
*-lft-identity94.0%
associate-/r*94.1%
associate-/l/99.0%
*-commutative99.0%
Simplified99.0%
*-un-lft-identity99.0%
times-frac98.0%
Applied egg-rr98.0%
Final simplification98.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ (/ 1.0 y) (* x (hypot 1.0 z))) (hypot 1.0 z)))
assert(x < y);
double code(double x, double y, double z) {
return ((1.0 / y) / (x * hypot(1.0, z))) / hypot(1.0, z);
}
assert x < y;
public static double code(double x, double y, double z) {
return ((1.0 / y) / (x * Math.hypot(1.0, z))) / Math.hypot(1.0, z);
}
[x, y] = sort([x, y]) def code(x, y, z): return ((1.0 / y) / (x * math.hypot(1.0, z))) / math.hypot(1.0, z)
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(Float64(1.0 / y) / Float64(x * hypot(1.0, z))) / hypot(1.0, z)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = ((1.0 / y) / (x * hypot(1.0, z))) / hypot(1.0, z);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{\frac{1}{y}}{x \cdot \mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right)}
\end{array}
Initial program 89.5%
associate-/r*89.1%
+-commutative89.1%
fma-def89.1%
Simplified89.1%
fma-udef89.1%
+-commutative89.1%
associate-/r*89.5%
associate-/r*89.3%
add-sqr-sqrt89.3%
*-un-lft-identity89.3%
times-frac89.3%
hypot-1-def89.3%
associate-/l/89.2%
hypot-1-def94.0%
Applied egg-rr94.0%
associate-*l/94.0%
*-lft-identity94.0%
associate-/r*94.1%
associate-/l/99.0%
*-commutative99.0%
Simplified99.0%
Final simplification99.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+41) (/ 1.0 (* x (+ y (* y (* z z))))) (/ (/ (/ (/ 1.0 y) z) x) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+41) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = (((1.0 / y) / z) / x) / z;
}
return tmp;
}
NOTE: x and y 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 * z) <= 4d+41) then
tmp = 1.0d0 / (x * (y + (y * (z * z))))
else
tmp = (((1.0d0 / y) / z) / x) / z
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+41) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = (((1.0 / y) / z) / x) / z;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 4e+41: tmp = 1.0 / (x * (y + (y * (z * z)))) else: tmp = (((1.0 / y) / z) / x) / z return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+41) tmp = Float64(1.0 / Float64(x * Float64(y + Float64(y * Float64(z * z))))); else tmp = Float64(Float64(Float64(Float64(1.0 / y) / z) / x) / z); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 4e+41)
tmp = 1.0 / (x * (y + (y * (z * z))));
else
tmp = (((1.0 / y) / z) / x) / z;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e+41], N[(1.0 / N[(x * N[(y + N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+41}:\\
\;\;\;\;\frac{1}{x \cdot \left(y + y \cdot \left(z \cdot z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{y}}{z}}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.00000000000000002e41Initial program 99.6%
associate-/r*99.5%
+-commutative99.5%
fma-def99.5%
Simplified99.5%
fma-udef99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
Applied egg-rr99.5%
if 4.00000000000000002e41 < (*.f64 z z) Initial program 78.8%
associate-/r*78.2%
+-commutative78.2%
fma-def78.2%
Simplified78.2%
Taylor expanded in z around inf 78.8%
associate-/r*79.5%
*-un-lft-identity79.5%
pow279.5%
times-frac78.4%
associate-/r*78.5%
Applied egg-rr78.5%
associate-*l/78.5%
*-un-lft-identity78.5%
associate-/r*88.3%
associate-/r*88.2%
associate-/r*98.2%
*-commutative98.2%
associate-/r*96.5%
Applied egg-rr96.5%
Final simplification98.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+233) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (/ 1.0 (* z (* y (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+233) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = 1.0 / (z * (y * (x * z)));
}
return tmp;
}
NOTE: x and y 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 * z) <= 2d+233) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = 1.0d0 / (z * (y * (x * z)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+233) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = 1.0 / (z * (y * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e+233: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = 1.0 / (z * (y * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+233) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(1.0 / Float64(z * Float64(y * Float64(x * z)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e+233)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = 1.0 / (z * (y * (x * z)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+233], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z * N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+233}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(x \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.99999999999999995e233Initial program 98.5%
if 1.99999999999999995e233 < (*.f64 z z) Initial program 71.6%
associate-/r*71.6%
+-commutative71.6%
fma-def71.6%
Simplified71.6%
Taylor expanded in z around inf 72.5%
unpow272.5%
*-commutative72.5%
associate-*l*72.1%
*-commutative72.1%
associate-*l*85.5%
Simplified85.5%
Taylor expanded in z around 0 98.8%
Final simplification98.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-5) (/ (/ 1.0 x) y) (/ 1.0 (* z (* y (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (z * (y * (x * z)));
}
return tmp;
}
NOTE: x and y 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 * z) <= 5d-5) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (z * (y * (x * z)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (z * (y * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-5: tmp = (1.0 / x) / y else: tmp = 1.0 / (z * (y * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(z * Float64(y * Float64(x * z)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e-5)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (z * (y * (x * z)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-5], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(z * N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(x \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.6%
associate-/r*99.5%
+-commutative99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in z around 0 99.0%
associate-/r*99.3%
div-inv99.1%
Applied egg-rr99.1%
associate-*l/99.2%
*-un-lft-identity99.2%
Applied egg-rr99.2%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 80.0%
associate-/r*79.5%
+-commutative79.5%
fma-def79.5%
Simplified79.5%
Taylor expanded in z around inf 78.8%
unpow278.8%
*-commutative78.8%
associate-*l*78.4%
*-commutative78.4%
associate-*l*87.1%
Simplified87.1%
Taylor expanded in z around 0 95.9%
Final simplification97.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-5) (/ (/ 1.0 x) y) (/ (/ 1.0 z) (* x (* y z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
NOTE: x and y 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 * z) <= 5d-5) then
tmp = (1.0d0 / x) / y
else
tmp = (1.0d0 / z) / (x * (y * z))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-5: tmp = (1.0 / x) / y else: tmp = (1.0 / z) / (x * (y * z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(1.0 / z) / Float64(x * Float64(y * z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e-5)
tmp = (1.0 / x) / y;
else
tmp = (1.0 / z) / (x * (y * z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-5], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(y \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.6%
associate-/r*99.5%
+-commutative99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in z around 0 99.0%
associate-/r*99.3%
div-inv99.1%
Applied egg-rr99.1%
associate-*l/99.2%
*-un-lft-identity99.2%
Applied egg-rr99.2%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 80.0%
associate-/r*79.5%
+-commutative79.5%
fma-def79.5%
Simplified79.5%
Taylor expanded in z around inf 78.8%
associate-/r*79.4%
*-un-lft-identity79.4%
pow279.4%
times-frac78.4%
associate-/r*78.4%
Applied egg-rr78.4%
frac-times78.4%
metadata-eval78.4%
associate-*r*87.1%
associate-/r*88.3%
*-commutative88.3%
*-commutative88.3%
associate-*l*95.2%
Applied egg-rr95.2%
Final simplification97.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-5) (/ (/ 1.0 x) y) (/ (/ (/ (/ 1.0 y) z) x) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = (((1.0 / y) / z) / x) / z;
}
return tmp;
}
NOTE: x and y 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 * z) <= 5d-5) then
tmp = (1.0d0 / x) / y
else
tmp = (((1.0d0 / y) / z) / x) / z
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = (((1.0 / y) / z) / x) / z;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-5: tmp = (1.0 / x) / y else: tmp = (((1.0 / y) / z) / x) / z return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(Float64(Float64(1.0 / y) / z) / x) / z); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e-5)
tmp = (1.0 / x) / y;
else
tmp = (((1.0 / y) / z) / x) / z;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-5], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{y}}{z}}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.6%
associate-/r*99.5%
+-commutative99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in z around 0 99.0%
associate-/r*99.3%
div-inv99.1%
Applied egg-rr99.1%
associate-*l/99.2%
*-un-lft-identity99.2%
Applied egg-rr99.2%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 80.0%
associate-/r*79.5%
+-commutative79.5%
fma-def79.5%
Simplified79.5%
Taylor expanded in z around inf 78.8%
associate-/r*79.4%
*-un-lft-identity79.4%
pow279.4%
times-frac78.4%
associate-/r*78.4%
Applied egg-rr78.4%
associate-*l/78.5%
*-un-lft-identity78.5%
associate-/r*87.7%
associate-/r*87.6%
associate-/r*97.0%
*-commutative97.0%
associate-/r*95.4%
Applied egg-rr95.4%
Final simplification97.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 1.0) (/ (/ 1.0 x) y) (/ 1.0 (* x (* z (* y z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (z * (y * z)));
}
return tmp;
}
NOTE: x and y 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 <= 1.0d0) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (x * (z * (y * z)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (z * (y * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 1.0: tmp = (1.0 / x) / y else: tmp = 1.0 / (x * (z * (y * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 1.0) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(x * Float64(z * Float64(y * z)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= 1.0)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (x * (z * (y * z)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, 1.0], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(x * N[(z * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\
\end{array}
\end{array}
if z < 1Initial program 91.2%
associate-/r*91.1%
+-commutative91.1%
fma-def91.1%
Simplified91.1%
Taylor expanded in z around 0 71.7%
associate-/r*71.9%
div-inv71.7%
Applied egg-rr71.7%
associate-*l/71.8%
*-un-lft-identity71.8%
Applied egg-rr71.8%
if 1 < z Initial program 84.9%
associate-/r*83.8%
+-commutative83.8%
fma-def83.8%
Simplified83.8%
Taylor expanded in z around inf 82.4%
unpow282.4%
associate-*r*92.0%
*-commutative92.0%
Simplified92.0%
Final simplification77.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 1.0) (/ (/ 1.0 x) y) (/ 1.0 (* y (* z (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (y * (z * (x * z)));
}
return tmp;
}
NOTE: x and y 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 <= 1.0d0) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (y * (z * (x * z)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (y * (z * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 1.0: tmp = (1.0 / x) / y else: tmp = 1.0 / (y * (z * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 1.0) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(y * Float64(z * Float64(x * z)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= 1.0)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (y * (z * (x * z)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, 1.0], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(y * N[(z * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(x \cdot z\right)\right)}\\
\end{array}
\end{array}
if z < 1Initial program 91.2%
associate-/r*91.1%
+-commutative91.1%
fma-def91.1%
Simplified91.1%
Taylor expanded in z around 0 71.7%
associate-/r*71.9%
div-inv71.7%
Applied egg-rr71.7%
associate-*l/71.8%
*-un-lft-identity71.8%
Applied egg-rr71.8%
if 1 < z Initial program 84.9%
associate-/r*83.8%
+-commutative83.8%
fma-def83.8%
Simplified83.8%
fma-udef83.8%
+-commutative83.8%
associate-/r*84.9%
associate-/r*80.5%
add-sqr-sqrt80.5%
*-un-lft-identity80.5%
times-frac80.5%
hypot-1-def80.5%
associate-/l/80.5%
hypot-1-def84.8%
Applied egg-rr84.8%
associate-*l/84.8%
*-lft-identity84.8%
associate-/r*84.8%
associate-/l/97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in z around inf 79.7%
associate-/r*80.9%
unpow280.9%
associate-*r*90.4%
associate-/r*89.3%
Simplified89.3%
Final simplification76.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ 1.0 (* x y)))
assert(x < y);
double code(double x, double y, double z) {
return 1.0 / (x * y);
}
NOTE: x and y 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 = 1.0d0 / (x * y)
end function
assert x < y;
public static double code(double x, double y, double z) {
return 1.0 / (x * y);
}
[x, y] = sort([x, y]) def code(x, y, z): return 1.0 / (x * y)
x, y = sort([x, y]) function code(x, y, z) return Float64(1.0 / Float64(x * y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = 1.0 / (x * y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{x \cdot y}
\end{array}
Initial program 89.5%
associate-/r*89.1%
+-commutative89.1%
fma-def89.1%
Simplified89.1%
Taylor expanded in z around 0 56.8%
Final simplification56.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 x) y))
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / x) / y;
}
NOTE: x and y 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 = (1.0d0 / x) / y
end function
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / x) / y;
}
[x, y] = sort([x, y]) def code(x, y, z): return (1.0 / x) / y
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / x) / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / x) / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{x}}{y}
\end{array}
Initial program 89.5%
associate-/r*89.1%
+-commutative89.1%
fma-def89.1%
Simplified89.1%
Taylor expanded in z around 0 56.8%
associate-/r*56.9%
div-inv56.8%
Applied egg-rr56.8%
associate-*l/56.9%
*-un-lft-identity56.9%
Applied egg-rr56.9%
Final simplification56.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z z))) (t_1 (* y t_0)) (t_2 (/ (/ 1.0 y) (* t_0 x))))
(if (< t_1 (- INFINITY))
t_2
(if (< t_1 8.680743250567252e+305) (/ (/ 1.0 x) (* t_0 y)) t_2))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * z) t_1 = y * t_0 t_2 = (1.0 / y) / (t_0 * x) tmp = 0 if t_1 < -math.inf: tmp = t_2 elif t_1 < 8.680743250567252e+305: tmp = (1.0 / x) / (t_0 * y) else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * z)) t_1 = Float64(y * t_0) t_2 = Float64(Float64(1.0 / y) / Float64(t_0 * x)) tmp = 0.0 if (t_1 < Float64(-Inf)) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = Float64(Float64(1.0 / x) / Float64(t_0 * y)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * z); t_1 = y * t_0; t_2 = (1.0 / y) / (t_0 * x); tmp = 0.0; if (t_1 < -Inf) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = (1.0 / x) / (t_0 * y); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / y), $MachinePrecision] / N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$1, (-Infinity)], t$95$2, If[Less[t$95$1, 8.680743250567252e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot z\\
t_1 := y \cdot t_0\\
t_2 := \frac{\frac{1}{y}}{t_0 \cdot x}\\
\mathbf{if}\;t_1 < -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 < 8.680743250567252 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0 \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
herbie shell --seed 2023253
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< (* y (+ 1.0 (* z z))) (- INFINITY)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x)) (if (< (* y (+ 1.0 (* z z))) 8.680743250567252e+305) (/ (/ 1.0 x) (* (+ 1.0 (* z z)) y)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x))))
(/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))