
(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 (<= y 2e-48) (* (/ (/ 1.0 x) (hypot 1.0 z)) (/ (/ 1.0 y) (hypot 1.0 z))) (/ (/ (/ 1.0 y) (* x (hypot 1.0 z))) (hypot 1.0 z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2e-48) {
tmp = ((1.0 / x) / hypot(1.0, z)) * ((1.0 / y) / hypot(1.0, z));
} else {
tmp = ((1.0 / y) / (x * hypot(1.0, z))) / hypot(1.0, z);
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2e-48) {
tmp = ((1.0 / x) / Math.hypot(1.0, z)) * ((1.0 / y) / Math.hypot(1.0, z));
} else {
tmp = ((1.0 / y) / (x * Math.hypot(1.0, z))) / Math.hypot(1.0, z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if y <= 2e-48: tmp = ((1.0 / x) / math.hypot(1.0, z)) * ((1.0 / y) / math.hypot(1.0, z)) else: tmp = ((1.0 / y) / (x * math.hypot(1.0, z))) / math.hypot(1.0, z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (y <= 2e-48) tmp = Float64(Float64(Float64(1.0 / x) / hypot(1.0, z)) * Float64(Float64(1.0 / y) / hypot(1.0, z))); else tmp = Float64(Float64(Float64(1.0 / y) / Float64(x * hypot(1.0, z))) / hypot(1.0, z)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 2e-48)
tmp = ((1.0 / x) / hypot(1.0, z)) * ((1.0 / y) / hypot(1.0, z));
else
tmp = ((1.0 / y) / (x * hypot(1.0, z))) / hypot(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[y, 2e-48], 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], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-48}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{y}}{\mathsf{hypot}\left(1, z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{y}}{x \cdot \mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right)}\\
\end{array}
\end{array}
if y < 1.9999999999999999e-48Initial program 86.1%
associate-/r*86.0%
+-commutative86.0%
fma-def86.0%
Simplified86.0%
fma-udef86.0%
+-commutative86.0%
associate-/r*86.1%
associate-/r*83.9%
div-inv83.9%
add-sqr-sqrt83.9%
times-frac85.6%
hypot-1-def85.6%
hypot-1-def97.1%
Applied egg-rr97.1%
if 1.9999999999999999e-48 < y Initial program 92.3%
associate-/r*90.8%
+-commutative90.8%
fma-def90.8%
Simplified90.8%
fma-udef90.8%
+-commutative90.8%
associate-/r*92.3%
associate-/r*96.3%
add-sqr-sqrt96.3%
*-un-lft-identity96.3%
times-frac96.2%
hypot-1-def96.2%
associate-/l/94.7%
hypot-1-def97.2%
Applied egg-rr97.2%
associate-*l/97.3%
*-lft-identity97.3%
associate-/r*98.8%
associate-/l/99.8%
*-commutative99.8%
Simplified99.8%
Final simplification98.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+304) (* (/ 1.0 y) (/ (/ 1.0 x) (fma z z 1.0))) (/ (/ 1.0 (* x (* y (hypot 1.0 z)))) (hypot 1.0 z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+304) {
tmp = (1.0 / y) * ((1.0 / x) / fma(z, z, 1.0));
} else {
tmp = (1.0 / (x * (y * hypot(1.0, z)))) / hypot(1.0, z);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+304) tmp = Float64(Float64(1.0 / y) * Float64(Float64(1.0 / x) / fma(z, z, 1.0))); else tmp = Float64(Float64(1.0 / Float64(x * Float64(y * hypot(1.0, z)))) / hypot(1.0, z)); end return 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+304], N[(N[(1.0 / y), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x * N[(y * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+304}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{\frac{1}{x}}{\mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot \left(y \cdot \mathsf{hypot}\left(1, z\right)\right)}}{\mathsf{hypot}\left(1, z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 3.9999999999999998e304Initial program 96.6%
associate-/r*95.8%
+-commutative95.8%
fma-def95.8%
Simplified95.8%
associate-/r*96.6%
*-un-lft-identity96.6%
fma-udef96.6%
+-commutative96.6%
times-frac97.9%
+-commutative97.9%
fma-udef97.9%
Applied egg-rr97.9%
if 3.9999999999999998e304 < (*.f64 z z) Initial program 68.9%
associate-/r*68.9%
+-commutative68.9%
fma-def68.9%
Simplified68.9%
fma-udef68.9%
+-commutative68.9%
associate-/r*68.9%
associate-/r*68.1%
div-inv68.1%
add-sqr-sqrt68.1%
times-frac68.9%
hypot-1-def68.9%
hypot-1-def97.7%
Applied egg-rr97.7%
associate-*l/98.6%
associate-/l/98.5%
frac-times98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Final simplification98.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+304) (* (/ 1.0 y) (/ (/ 1.0 x) (fma z z 1.0))) (/ 1.0 (/ z (/ 1.0 (* x (* y z)))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+304) {
tmp = (1.0 / y) * ((1.0 / x) / fma(z, z, 1.0));
} else {
tmp = 1.0 / (z / (1.0 / (x * (y * z))));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+304) tmp = Float64(Float64(1.0 / y) * Float64(Float64(1.0 / x) / fma(z, z, 1.0))); else tmp = Float64(1.0 / Float64(z / Float64(1.0 / Float64(x * Float64(y * z))))); end return 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+304], N[(N[(1.0 / y), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z / N[(1.0 / N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+304}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{\frac{1}{x}}{\mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z}{\frac{1}{x \cdot \left(y \cdot z\right)}}}\\
\end{array}
\end{array}
if (*.f64 z z) < 3.9999999999999998e304Initial program 96.6%
associate-/r*95.8%
+-commutative95.8%
fma-def95.8%
Simplified95.8%
associate-/r*96.6%
*-un-lft-identity96.6%
fma-udef96.6%
+-commutative96.6%
times-frac97.9%
+-commutative97.9%
fma-udef97.9%
Applied egg-rr97.9%
if 3.9999999999999998e304 < (*.f64 z z) Initial program 68.9%
associate-/r*68.9%
+-commutative68.9%
fma-def68.9%
Simplified68.9%
Taylor expanded in z around inf 68.9%
unpow268.9%
associate-*r*86.3%
*-commutative86.3%
Simplified86.3%
*-commutative86.3%
*-commutative86.3%
associate-*r*97.4%
associate-*r*85.2%
/-rgt-identity85.2%
associate-/l*85.2%
associate-*r*97.4%
*-commutative97.4%
Applied egg-rr97.4%
Final simplification97.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (let* ((t_0 (* y (+ 1.0 (* z z))))) (if (<= t_0 INFINITY) (/ (/ 1.0 x) t_0) (/ (/ 1.0 (* y (* x z))) z))))
assert(x < y);
double code(double x, double y, double z) {
double t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / (y * (x * z))) / z;
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / (y * (x * z))) / z;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): t_0 = y * (1.0 + (z * z)) tmp = 0 if t_0 <= math.inf: tmp = (1.0 / x) / t_0 else: tmp = (1.0 / (y * (x * z))) / z return tmp
x, y = sort([x, y]) function code(x, y, z) t_0 = Float64(y * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(1.0 / Float64(y * Float64(x * z))) / z); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
t_0 = y * (1.0 + (z * z));
tmp = 0.0;
if (t_0 <= Inf)
tmp = (1.0 / x) / t_0;
else
tmp = (1.0 / (y * (x * z))) / z;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + z \cdot z\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(x \cdot z\right)}}{z}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < +inf.0Initial program 88.4%
if +inf.0 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 88.4%
associate-/r*87.8%
+-commutative87.8%
fma-def87.8%
Simplified87.8%
Taylor expanded in z around inf 51.3%
unpow251.3%
associate-*r*56.5%
*-commutative56.5%
Simplified56.5%
*-commutative56.5%
*-commutative56.5%
*-commutative56.5%
associate-*r*51.3%
associate-*l*52.0%
associate-/l/52.0%
*-un-lft-identity52.0%
associate-*r*57.2%
times-frac60.2%
Applied egg-rr60.2%
associate-*r/60.8%
frac-times61.2%
metadata-eval61.2%
*-commutative61.2%
Applied egg-rr61.2%
Final simplification88.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e-51) (/ (/ 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 * z) <= 1e-51) {
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 * z) <= 1d-51) 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 * z) <= 1e-51) {
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 * z) <= 1e-51: 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 (Float64(z * z) <= 1e-51) 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 * z) <= 1e-51)
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[N[(z * z), $MachinePrecision], 1e-51], 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 \cdot z \leq 10^{-51}:\\
\;\;\;\;\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 (*.f64 z z) < 1e-51Initial program 99.7%
associate-/r*98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
fma-udef98.4%
+-commutative98.4%
associate-/r*99.7%
associate-/r*99.7%
div-inv99.6%
add-sqr-sqrt99.6%
times-frac99.6%
hypot-1-def99.6%
hypot-1-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 98.4%
associate-/l/99.7%
Simplified99.7%
if 1e-51 < (*.f64 z z) Initial program 79.3%
associate-/r*79.2%
+-commutative79.2%
fma-def79.2%
Simplified79.2%
Taylor expanded in z around inf 78.9%
unpow278.9%
associate-*r*88.2%
*-commutative88.2%
Simplified88.2%
Final simplification93.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e-51) (/ (/ 1.0 x) y) (/ 1.0 (* z (* z (* y x))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e-51) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (z * (z * (y * x)));
}
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) <= 1d-51) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (z * (z * (y * x)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e-51) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (z * (z * (y * x)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 1e-51: tmp = (1.0 / x) / y else: tmp = 1.0 / (z * (z * (y * x))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e-51) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(z * Float64(z * Float64(y * x)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 1e-51)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (z * (z * (y * x)));
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], 1e-51], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(z * N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{-51}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(y \cdot x\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e-51Initial program 99.7%
associate-/r*98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
fma-udef98.4%
+-commutative98.4%
associate-/r*99.7%
associate-/r*99.7%
div-inv99.6%
add-sqr-sqrt99.6%
times-frac99.6%
hypot-1-def99.6%
hypot-1-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 98.4%
associate-/l/99.7%
Simplified99.7%
if 1e-51 < (*.f64 z z) Initial program 79.3%
associate-/r*79.2%
+-commutative79.2%
fma-def79.2%
Simplified79.2%
Taylor expanded in z around inf 80.2%
unpow280.2%
*-commutative80.2%
associate-*l*79.9%
*-commutative79.9%
associate-*l*88.9%
Simplified88.9%
Final simplification93.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e-51) (/ (/ 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) <= 1e-51) {
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) <= 1d-51) 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) <= 1e-51) {
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) <= 1e-51: 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) <= 1e-51) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(Float64(y * 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 * z) <= 1e-51)
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], 1e-51], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(N[(y * z), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{-51}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(y \cdot z\right) \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e-51Initial program 99.7%
associate-/r*98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
fma-udef98.4%
+-commutative98.4%
associate-/r*99.7%
associate-/r*99.7%
div-inv99.6%
add-sqr-sqrt99.6%
times-frac99.6%
hypot-1-def99.6%
hypot-1-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 98.4%
associate-/l/99.7%
Simplified99.7%
if 1e-51 < (*.f64 z z) Initial program 79.3%
associate-/r*79.2%
+-commutative79.2%
fma-def79.2%
Simplified79.2%
Taylor expanded in z around inf 78.9%
unpow278.9%
associate-*r*88.2%
*-commutative88.2%
Simplified88.2%
*-commutative88.2%
*-commutative88.2%
*-commutative88.2%
associate-*r*78.9%
associate-*l*80.2%
associate-/l/80.2%
*-un-lft-identity80.2%
associate-*r*89.6%
times-frac94.9%
Applied egg-rr94.9%
*-commutative94.9%
associate-/l/94.0%
frac-times93.6%
metadata-eval93.6%
*-commutative93.6%
Applied egg-rr93.6%
Final simplification96.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e-51) (/ (/ 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) <= 1e-51) {
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) <= 1d-51) 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) <= 1e-51) {
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) <= 1e-51: 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) <= 1e-51) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(1.0 / Float64(y * 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 * z) <= 1e-51)
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], 1e-51], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{-51}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot z}}{x \cdot z}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e-51Initial program 99.7%
associate-/r*98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
fma-udef98.4%
+-commutative98.4%
associate-/r*99.7%
associate-/r*99.7%
div-inv99.6%
add-sqr-sqrt99.6%
times-frac99.6%
hypot-1-def99.6%
hypot-1-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 98.4%
associate-/l/99.7%
Simplified99.7%
if 1e-51 < (*.f64 z z) Initial program 79.3%
associate-/r*79.2%
+-commutative79.2%
fma-def79.2%
Simplified79.2%
Taylor expanded in z around inf 78.9%
unpow278.9%
associate-*r*88.2%
*-commutative88.2%
Simplified88.2%
*-commutative88.2%
*-commutative88.2%
*-commutative88.2%
associate-*r*78.9%
associate-*l*80.2%
associate-/l/80.2%
*-un-lft-identity80.2%
associate-*r*89.6%
times-frac94.9%
Applied egg-rr94.9%
associate-*l/94.9%
*-un-lft-identity94.9%
div-inv94.8%
frac-times94.0%
metadata-eval94.0%
*-commutative94.0%
Applied egg-rr94.0%
Final simplification96.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e-51) (/ (/ 1.0 x) y) (/ (/ 1.0 (* y (* x z))) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e-51) {
tmp = (1.0 / x) / y;
} else {
tmp = (1.0 / (y * (x * z))) / 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) <= 1d-51) then
tmp = (1.0d0 / x) / y
else
tmp = (1.0d0 / (y * (x * z))) / 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) <= 1e-51) {
tmp = (1.0 / x) / y;
} else {
tmp = (1.0 / (y * (x * z))) / z;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 1e-51: tmp = (1.0 / x) / y else: tmp = (1.0 / (y * (x * z))) / z return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e-51) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(1.0 / Float64(y * Float64(x * z))) / z); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 1e-51)
tmp = (1.0 / x) / y;
else
tmp = (1.0 / (y * (x * z))) / 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], 1e-51], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{-51}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(x \cdot z\right)}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e-51Initial program 99.7%
associate-/r*98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
fma-udef98.4%
+-commutative98.4%
associate-/r*99.7%
associate-/r*99.7%
div-inv99.6%
add-sqr-sqrt99.6%
times-frac99.6%
hypot-1-def99.6%
hypot-1-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 98.4%
associate-/l/99.7%
Simplified99.7%
if 1e-51 < (*.f64 z z) Initial program 79.3%
associate-/r*79.2%
+-commutative79.2%
fma-def79.2%
Simplified79.2%
Taylor expanded in z around inf 78.9%
unpow278.9%
associate-*r*88.2%
*-commutative88.2%
Simplified88.2%
*-commutative88.2%
*-commutative88.2%
*-commutative88.2%
associate-*r*78.9%
associate-*l*80.2%
associate-/l/80.2%
*-un-lft-identity80.2%
associate-*r*89.6%
times-frac94.9%
Applied egg-rr94.9%
associate-*r/94.1%
frac-times94.1%
metadata-eval94.1%
*-commutative94.1%
Applied egg-rr94.1%
Final simplification96.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 5.4e+152) (/ (/ 1.0 y) (* x (+ 1.0 (* z z)))) (/ 1.0 (/ z (/ 1.0 (* x (* y z)))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 5.4e+152) {
tmp = (1.0 / y) / (x * (1.0 + (z * z)));
} else {
tmp = 1.0 / (z / (1.0 / (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 <= 5.4d+152) then
tmp = (1.0d0 / y) / (x * (1.0d0 + (z * z)))
else
tmp = 1.0d0 / (z / (1.0d0 / (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 <= 5.4e+152) {
tmp = (1.0 / y) / (x * (1.0 + (z * z)));
} else {
tmp = 1.0 / (z / (1.0 / (x * (y * z))));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 5.4e+152: tmp = (1.0 / y) / (x * (1.0 + (z * z))) else: tmp = 1.0 / (z / (1.0 / (x * (y * z)))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 5.4e+152) tmp = Float64(Float64(1.0 / y) / Float64(x * Float64(1.0 + Float64(z * z)))); else tmp = Float64(1.0 / Float64(z / Float64(1.0 / 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 <= 5.4e+152)
tmp = (1.0 / y) / (x * (1.0 + (z * z)));
else
tmp = 1.0 / (z / (1.0 / (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[z, 5.4e+152], N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z / N[(1.0 / N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.4 \cdot 10^{+152}:\\
\;\;\;\;\frac{\frac{1}{y}}{x \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z}{\frac{1}{x \cdot \left(y \cdot z\right)}}}\\
\end{array}
\end{array}
if z < 5.4000000000000003e152Initial program 93.4%
associate-/r*92.7%
+-commutative92.7%
fma-def92.7%
Simplified92.7%
fma-udef92.7%
+-commutative92.7%
associate-/r*93.4%
associate-/r*93.7%
div-inv93.6%
add-sqr-sqrt93.6%
times-frac93.9%
hypot-1-def93.9%
hypot-1-def97.1%
Applied egg-rr97.1%
associate-*l/97.2%
associate-/l/96.6%
frac-times96.0%
metadata-eval96.0%
Applied egg-rr96.0%
Taylor expanded in x around 0 93.5%
associate-/r*94.3%
unpow294.3%
+-commutative94.3%
Simplified94.3%
if 5.4000000000000003e152 < z Initial program 64.2%
associate-/r*64.2%
+-commutative64.2%
fma-def64.2%
Simplified64.2%
Taylor expanded in z around inf 64.2%
unpow264.2%
associate-*r*83.7%
*-commutative83.7%
Simplified83.7%
*-commutative83.7%
*-commutative83.7%
associate-*r*96.6%
associate-*r*79.9%
/-rgt-identity79.9%
associate-/l*79.9%
associate-*r*96.5%
*-commutative96.5%
Applied egg-rr96.5%
Final simplification94.7%
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(1.0 / Float64(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[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{y \cdot x}
\end{array}
Initial program 88.4%
associate-/r*87.8%
+-commutative87.8%
fma-def87.8%
Simplified87.8%
Taylor expanded in z around 0 53.7%
Final simplification53.7%
(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 2023200
(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)))))