
(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 11 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) 5e+246) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (* (/ 1.0 (* y (* x z))) (/ 1.0 z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+246) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / (y * (x * z))) * (1.0 / 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+246) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = (1.0d0 / (y * (x * z))) * (1.0d0 / 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+246) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / (y * (x * z))) * (1.0 / z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e+246: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = (1.0 / (y * (x * z))) * (1.0 / z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+246) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(1.0 / Float64(y * Float64(x * z))) * Float64(1.0 / 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+246)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = (1.0 / (y * (x * z))) * (1.0 / 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+246], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+246}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(x \cdot z\right)} \cdot \frac{1}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999976e246Initial program 97.4%
if 4.99999999999999976e246 < (*.f64 z z) Initial program 73.2%
associate-/r*72.9%
+-commutative72.9%
fma-def72.9%
Simplified72.9%
fma-udef72.9%
+-commutative72.9%
associate-/r*73.2%
associate-/r*73.0%
add-sqr-sqrt73.0%
*-un-lft-identity73.0%
times-frac73.0%
hypot-1-def73.0%
associate-/l/73.0%
hypot-1-def89.6%
Applied egg-rr89.6%
*-commutative89.6%
associate-/l/89.9%
Simplified89.9%
Taylor expanded in z around inf 74.7%
Taylor expanded in z around inf 96.2%
Final simplification97.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* (/ (/ 1.0 x) (hypot 1.0 z)) (/ (/ 1.0 y) (hypot 1.0 z))))
assert(x < y);
double code(double x, double y, double z) {
return ((1.0 / x) / hypot(1.0, z)) * ((1.0 / y) / hypot(1.0, z));
}
assert x < y;
public static double code(double x, double y, double z) {
return ((1.0 / x) / Math.hypot(1.0, z)) * ((1.0 / y) / Math.hypot(1.0, z));
}
[x, y] = sort([x, y]) def code(x, y, z): return ((1.0 / x) / math.hypot(1.0, z)) * ((1.0 / y) / math.hypot(1.0, z))
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(Float64(1.0 / x) / hypot(1.0, z)) * Float64(Float64(1.0 / y) / hypot(1.0, z))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = ((1.0 / x) / hypot(1.0, z)) * ((1.0 / y) / 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[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / y), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{y}}{\mathsf{hypot}\left(1, z\right)}
\end{array}
Initial program 89.4%
associate-/r*89.0%
+-commutative89.0%
fma-def89.0%
Simplified89.0%
fma-udef89.0%
+-commutative89.0%
associate-/r*89.4%
associate-/r*89.3%
div-inv89.2%
add-sqr-sqrt89.2%
times-frac91.0%
hypot-1-def91.0%
hypot-1-def97.9%
Applied egg-rr97.9%
Final simplification97.9%
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.4%
associate-/r*89.0%
+-commutative89.0%
fma-def89.0%
Simplified89.0%
fma-udef89.0%
+-commutative89.0%
associate-/r*89.4%
associate-/r*89.3%
add-sqr-sqrt89.3%
*-un-lft-identity89.3%
times-frac89.3%
hypot-1-def89.3%
associate-/l/89.0%
hypot-1-def94.5%
Applied egg-rr94.5%
associate-*l/94.5%
*-lft-identity94.5%
associate-/r*94.4%
associate-/l/97.3%
*-commutative97.3%
Simplified97.3%
Final simplification97.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e-17) (/ (/ 1.0 y) x) (* (/ 1.0 (* y (* x z))) (/ 1.0 z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-17) {
tmp = (1.0 / y) / x;
} else {
tmp = (1.0 / (y * (x * z))) * (1.0 / 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-17) then
tmp = (1.0d0 / y) / x
else
tmp = (1.0d0 / (y * (x * z))) * (1.0d0 / 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-17) {
tmp = (1.0 / y) / x;
} else {
tmp = (1.0 / (y * (x * z))) * (1.0 / z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e-17: tmp = (1.0 / y) / x else: tmp = (1.0 / (y * (x * z))) * (1.0 / z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e-17) tmp = Float64(Float64(1.0 / y) / x); else tmp = Float64(Float64(1.0 / Float64(y * Float64(x * z))) * Float64(1.0 / 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-17)
tmp = (1.0 / y) / x;
else
tmp = (1.0 / (y * (x * z))) * (1.0 / 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-17], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(x \cdot z\right)} \cdot \frac{1}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000014e-17Initial program 99.6%
associate-/r*99.0%
+-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
+-commutative99.0%
associate-/r*99.6%
associate-/r*99.6%
div-inv99.5%
add-sqr-sqrt99.5%
times-frac99.5%
hypot-1-def99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 99.0%
associate-/r*99.6%
*-commutative99.6%
unpow299.6%
fma-udef99.6%
Simplified99.6%
Taylor expanded in z around 0 99.6%
if 2.00000000000000014e-17 < (*.f64 z z) Initial program 80.3%
associate-/r*80.1%
+-commutative80.1%
fma-def80.1%
Simplified80.1%
fma-udef80.1%
+-commutative80.1%
associate-/r*80.3%
associate-/r*80.2%
add-sqr-sqrt80.2%
*-un-lft-identity80.2%
times-frac80.2%
hypot-1-def80.2%
associate-/l/80.2%
hypot-1-def90.5%
Applied egg-rr90.5%
*-commutative90.5%
associate-/l/90.7%
Simplified90.7%
Taylor expanded in z around inf 67.8%
Taylor expanded in z around inf 94.7%
Final simplification97.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-17) (/ (/ 1.0 y) x) (/ 1.0 (* x (* z (* z y))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-17) {
tmp = (1.0 / y) / x;
} else {
tmp = 1.0 / (x * (z * (z * y)));
}
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-17) then
tmp = (1.0d0 / y) / x
else
tmp = 1.0d0 / (x * (z * (z * y)))
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-17) {
tmp = (1.0 / y) / x;
} else {
tmp = 1.0 / (x * (z * (z * y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e-17: tmp = (1.0 / y) / x else: tmp = 1.0 / (x * (z * (z * y))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e-17) tmp = Float64(Float64(1.0 / y) / x); else tmp = Float64(1.0 / Float64(x * Float64(z * Float64(z * y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e-17)
tmp = (1.0 / y) / x;
else
tmp = 1.0 / (x * (z * (z * y)));
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-17], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(x * N[(z * N[(z * y), $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^{-17}:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000014e-17Initial program 99.6%
associate-/r*99.0%
+-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
+-commutative99.0%
associate-/r*99.6%
associate-/r*99.6%
div-inv99.5%
add-sqr-sqrt99.5%
times-frac99.5%
hypot-1-def99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 99.0%
associate-/r*99.6%
*-commutative99.6%
unpow299.6%
fma-udef99.6%
Simplified99.6%
Taylor expanded in z around 0 99.6%
if 2.00000000000000014e-17 < (*.f64 z z) Initial program 80.3%
associate-/r*80.1%
+-commutative80.1%
fma-def80.1%
Simplified80.1%
Taylor expanded in z around inf 79.5%
unpow279.5%
associate-*r*87.8%
*-commutative87.8%
Simplified87.8%
Final simplification93.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e-17) (/ (/ 1.0 y) x) (/ 1.0 (* z (* y (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-17) {
tmp = (1.0 / y) / x;
} 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-17) then
tmp = (1.0d0 / y) / x
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-17) {
tmp = (1.0 / y) / x;
} 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-17: tmp = (1.0 / y) / x 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-17) tmp = Float64(Float64(1.0 / y) / x); 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-17)
tmp = (1.0 / y) / x;
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-17], N[(N[(1.0 / y), $MachinePrecision] / x), $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^{-17}:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(x \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000014e-17Initial program 99.6%
associate-/r*99.0%
+-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
+-commutative99.0%
associate-/r*99.6%
associate-/r*99.6%
div-inv99.5%
add-sqr-sqrt99.5%
times-frac99.5%
hypot-1-def99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 99.0%
associate-/r*99.6%
*-commutative99.6%
unpow299.6%
fma-udef99.6%
Simplified99.6%
Taylor expanded in z around 0 99.6%
if 2.00000000000000014e-17 < (*.f64 z z) Initial program 80.3%
associate-/r*80.1%
+-commutative80.1%
fma-def80.1%
Simplified80.1%
fma-udef80.1%
+-commutative80.1%
associate-/r*80.3%
associate-/r*80.2%
div-inv80.2%
add-sqr-sqrt80.2%
times-frac83.5%
hypot-1-def83.5%
hypot-1-def96.5%
Applied egg-rr96.5%
Taylor expanded in z around inf 79.5%
unpow279.5%
Simplified79.5%
expm1-log1p-u44.4%
expm1-udef35.6%
*-commutative35.6%
associate-*l*41.2%
associate-*l*42.5%
*-commutative42.5%
associate-*l*42.5%
Applied egg-rr42.5%
expm1-def50.7%
expm1-log1p94.7%
associate-*r*94.7%
*-commutative94.7%
Simplified94.7%
Final simplification97.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-17) (/ (/ 1.0 y) x) (/ 1.0 (* z (* x (* z y))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-17) {
tmp = (1.0 / y) / x;
} else {
tmp = 1.0 / (z * (x * (z * y)));
}
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-17) then
tmp = (1.0d0 / y) / x
else
tmp = 1.0d0 / (z * (x * (z * y)))
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-17) {
tmp = (1.0 / y) / x;
} else {
tmp = 1.0 / (z * (x * (z * y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e-17: tmp = (1.0 / y) / x else: tmp = 1.0 / (z * (x * (z * y))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e-17) tmp = Float64(Float64(1.0 / y) / x); else tmp = Float64(1.0 / Float64(z * Float64(x * Float64(z * y)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e-17)
tmp = (1.0 / y) / x;
else
tmp = 1.0 / (z * (x * (z * y)));
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-17], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(z * N[(x * N[(z * y), $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^{-17}:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000014e-17Initial program 99.6%
associate-/r*99.0%
+-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
+-commutative99.0%
associate-/r*99.6%
associate-/r*99.6%
div-inv99.5%
add-sqr-sqrt99.5%
times-frac99.5%
hypot-1-def99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 99.0%
associate-/r*99.6%
*-commutative99.6%
unpow299.6%
fma-udef99.6%
Simplified99.6%
Taylor expanded in z around 0 99.6%
if 2.00000000000000014e-17 < (*.f64 z z) Initial program 80.3%
associate-/r*80.1%
+-commutative80.1%
fma-def80.1%
Simplified80.1%
fma-udef80.1%
+-commutative80.1%
associate-/r*80.3%
associate-/r*80.2%
div-inv80.2%
add-sqr-sqrt80.2%
times-frac83.5%
hypot-1-def83.5%
hypot-1-def96.5%
Applied egg-rr96.5%
Taylor expanded in z around inf 79.5%
unpow279.5%
Simplified79.5%
/-rgt-identity79.5%
*-commutative79.5%
associate-*l*89.8%
associate-*l*94.7%
*-commutative94.7%
associate-*l*94.7%
Applied egg-rr94.7%
Final simplification97.0%
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 y) x) (/ 1.0 (* y (* x z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / y) / x;
} else {
tmp = 1.0 / (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 <= 1.0d0) then
tmp = (1.0d0 / y) / x
else
tmp = 1.0d0 / (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 <= 1.0) {
tmp = (1.0 / y) / x;
} else {
tmp = 1.0 / (y * (x * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 1.0: tmp = (1.0 / y) / x else: tmp = 1.0 / (y * (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 / y) / x); else tmp = Float64(1.0 / 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 <= 1.0)
tmp = (1.0 / y) / x;
else
tmp = 1.0 / (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[z, 1.0], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if z < 1Initial program 91.2%
associate-/r*90.9%
+-commutative90.9%
fma-def90.9%
Simplified90.9%
fma-udef90.9%
+-commutative90.9%
associate-/r*91.2%
associate-/r*91.2%
div-inv91.1%
add-sqr-sqrt91.1%
times-frac92.3%
hypot-1-def92.3%
hypot-1-def98.2%
Applied egg-rr98.2%
Taylor expanded in x around 0 90.9%
associate-/r*91.2%
*-commutative91.2%
unpow291.2%
fma-udef91.2%
Simplified91.2%
Taylor expanded in z around 0 67.4%
if 1 < z Initial program 83.9%
associate-/r*83.4%
+-commutative83.4%
fma-def83.4%
Simplified83.4%
fma-udef83.4%
+-commutative83.4%
associate-/r*83.9%
associate-/r*83.8%
add-sqr-sqrt83.8%
*-un-lft-identity83.8%
times-frac83.7%
hypot-1-def83.7%
associate-/l/83.7%
hypot-1-def92.4%
Applied egg-rr92.4%
*-commutative92.4%
associate-/l/92.3%
Simplified92.3%
Taylor expanded in z around inf 96.7%
Taylor expanded in z around 0 32.8%
Final simplification58.7%
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.4%
associate-/r*89.0%
+-commutative89.0%
fma-def89.0%
Simplified89.0%
Taylor expanded in z around 0 53.6%
Final simplification53.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(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.4%
associate-/r*89.0%
+-commutative89.0%
fma-def89.0%
Simplified89.0%
add-cube-cbrt88.2%
pow388.2%
fma-udef88.2%
distribute-lft-in88.2%
*-rgt-identity88.2%
fma-def88.2%
Applied egg-rr88.2%
Taylor expanded in z around 0 53.6%
associate-/l/53.6%
Simplified53.6%
Final simplification53.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 y) x))
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / y) / x;
}
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 / y) / x
end function
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / y) / x;
}
[x, y] = sort([x, y]) def code(x, y, z): return (1.0 / y) / x
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / y) / x) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / y) / x;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{y}}{x}
\end{array}
Initial program 89.4%
associate-/r*89.0%
+-commutative89.0%
fma-def89.0%
Simplified89.0%
fma-udef89.0%
+-commutative89.0%
associate-/r*89.4%
associate-/r*89.3%
div-inv89.2%
add-sqr-sqrt89.2%
times-frac91.0%
hypot-1-def91.0%
hypot-1-def97.9%
Applied egg-rr97.9%
Taylor expanded in x around 0 88.9%
associate-/r*89.2%
*-commutative89.2%
unpow289.2%
fma-udef89.2%
Simplified89.2%
Taylor expanded in z around 0 53.6%
Final simplification53.6%
(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 2023240
(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)))))