
(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 9 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
(let* ((t_0 (* (hypot 1.0 z) (sqrt y))))
(if (<= (* y (+ 1.0 (* z z))) 5e+300)
(/ (/ 1.0 x) (+ y (* z (* y z))))
(/ 1.0 (/ t_0 (/ (/ 1.0 x) t_0))))))assert(x < y);
double code(double x, double y, double z) {
double t_0 = hypot(1.0, z) * sqrt(y);
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+300) {
tmp = (1.0 / x) / (y + (z * (y * z)));
} else {
tmp = 1.0 / (t_0 / ((1.0 / x) / t_0));
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z) {
double t_0 = Math.hypot(1.0, z) * Math.sqrt(y);
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+300) {
tmp = (1.0 / x) / (y + (z * (y * z)));
} else {
tmp = 1.0 / (t_0 / ((1.0 / x) / t_0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): t_0 = math.hypot(1.0, z) * math.sqrt(y) tmp = 0 if (y * (1.0 + (z * z))) <= 5e+300: tmp = (1.0 / x) / (y + (z * (y * z))) else: tmp = 1.0 / (t_0 / ((1.0 / x) / t_0)) return tmp
x, y = sort([x, y]) function code(x, y, z) t_0 = Float64(hypot(1.0, z) * sqrt(y)) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 5e+300) tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(z * Float64(y * z)))); else tmp = Float64(1.0 / Float64(t_0 / Float64(Float64(1.0 / x) / t_0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
t_0 = hypot(1.0, z) * sqrt(y);
tmp = 0.0;
if ((y * (1.0 + (z * z))) <= 5e+300)
tmp = (1.0 / x) / (y + (z * (y * z)));
else
tmp = 1.0 / (t_0 / ((1.0 / x) / t_0));
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[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+300], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(z * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 / N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\\
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+300}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{t_0}{\frac{\frac{1}{x}}{t_0}}}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 5.00000000000000026e300Initial program 94.2%
distribute-lft-in94.2%
*-rgt-identity94.2%
+-commutative94.2%
associate-*r*97.1%
fma-def97.1%
Applied egg-rr97.1%
fma-udef97.1%
Applied egg-rr97.1%
if 5.00000000000000026e300 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 77.8%
associate-/r*77.8%
*-commutative77.8%
sqr-neg77.8%
+-commutative77.8%
distribute-lft1-in77.8%
*-commutative77.8%
fma-def77.8%
sqr-neg77.8%
Simplified77.8%
*-commutative77.8%
fma-udef77.8%
*-rgt-identity77.8%
distribute-lft-in77.8%
+-commutative77.8%
/-rgt-identity77.8%
clear-num77.8%
div-inv77.8%
add-sqr-sqrt77.8%
associate-/l*77.8%
+-commutative77.8%
fma-udef77.8%
*-commutative77.8%
sqrt-prod77.8%
fma-udef77.8%
+-commutative77.8%
hypot-1-def77.8%
+-commutative77.8%
fma-udef77.8%
*-commutative77.8%
sqrt-prod81.0%
Applied egg-rr99.7%
Final simplification97.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 8.5e-10) (/ (/ 1.0 x) (+ y (* z (* y z)))) (/ 1.0 (* (hypot 1.0 z) (* (hypot 1.0 z) (* y x))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (y <= 8.5e-10) {
tmp = (1.0 / x) / (y + (z * (y * z)));
} else {
tmp = 1.0 / (hypot(1.0, z) * (hypot(1.0, z) * (y * x)));
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 8.5e-10) {
tmp = (1.0 / x) / (y + (z * (y * z)));
} else {
tmp = 1.0 / (Math.hypot(1.0, z) * (Math.hypot(1.0, z) * (y * x)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if y <= 8.5e-10: tmp = (1.0 / x) / (y + (z * (y * z))) else: tmp = 1.0 / (math.hypot(1.0, z) * (math.hypot(1.0, z) * (y * x))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (y <= 8.5e-10) tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(z * Float64(y * z)))); else tmp = Float64(1.0 / Float64(hypot(1.0, z) * Float64(hypot(1.0, 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 (y <= 8.5e-10)
tmp = (1.0 / x) / (y + (z * (y * z)));
else
tmp = 1.0 / (hypot(1.0, z) * (hypot(1.0, 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[y, 8.5e-10], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(z * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(1, z\right) \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \left(y \cdot x\right)\right)}\\
\end{array}
\end{array}
if y < 8.4999999999999996e-10Initial program 91.4%
distribute-lft-in91.4%
*-rgt-identity91.4%
+-commutative91.4%
associate-*r*96.7%
fma-def96.7%
Applied egg-rr96.7%
fma-udef96.7%
Applied egg-rr96.7%
if 8.4999999999999996e-10 < y Initial program 95.1%
associate-/r*95.2%
*-commutative95.2%
sqr-neg95.2%
+-commutative95.2%
distribute-lft1-in95.2%
*-commutative95.2%
fma-def95.2%
sqr-neg95.2%
Simplified95.2%
associate-/r*95.1%
fma-udef95.1%
*-rgt-identity95.1%
distribute-lft-in95.1%
+-commutative95.1%
associate-/r*96.7%
associate-/r*96.7%
*-un-lft-identity96.7%
+-commutative96.7%
fma-udef96.7%
add-sqr-sqrt96.7%
times-frac96.7%
fma-udef96.7%
+-commutative96.7%
hypot-1-def96.7%
*-commutative96.7%
associate-/r*96.7%
fma-udef96.7%
+-commutative96.7%
hypot-1-def99.7%
Applied egg-rr99.7%
clear-num99.7%
frac-times99.6%
metadata-eval99.6%
div-inv99.6%
associate-/r*99.7%
clear-num99.8%
/-rgt-identity99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification97.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y (+ 1.0 (* z z))) 4e+306) (/ (/ 1.0 x) (+ y (* z (* y z)))) (/ (/ (/ 1.0 y) z) (* z x))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 4e+306) {
tmp = (1.0 / x) / (y + (z * (y * z)));
} else {
tmp = ((1.0 / y) / z) / (z * 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 ((y * (1.0d0 + (z * z))) <= 4d+306) then
tmp = (1.0d0 / x) / (y + (z * (y * z)))
else
tmp = ((1.0d0 / y) / z) / (z * x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 4e+306) {
tmp = (1.0 / x) / (y + (z * (y * z)));
} else {
tmp = ((1.0 / y) / z) / (z * x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (y * (1.0 + (z * z))) <= 4e+306: tmp = (1.0 / x) / (y + (z * (y * z))) else: tmp = ((1.0 / y) / z) / (z * x) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 4e+306) tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(z * Float64(y * z)))); else tmp = Float64(Float64(Float64(1.0 / y) / z) / Float64(z * x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((y * (1.0 + (z * z))) <= 4e+306)
tmp = (1.0 / x) / (y + (z * (y * z)));
else
tmp = ((1.0 / y) / z) / (z * 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[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+306], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(z * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 4 \cdot 10^{+306}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + z \cdot \left(y \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{y}}{z}}{z \cdot x}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 4.00000000000000007e306Initial program 94.2%
distribute-lft-in94.2%
*-rgt-identity94.2%
+-commutative94.2%
associate-*r*97.1%
fma-def97.1%
Applied egg-rr97.1%
fma-udef97.1%
Applied egg-rr97.1%
if 4.00000000000000007e306 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 77.8%
distribute-lft-in77.8%
*-rgt-identity77.8%
+-commutative77.8%
associate-*r*90.6%
fma-def90.6%
Applied egg-rr90.6%
Taylor expanded in z around inf 81.0%
unpow281.0%
Simplified81.0%
associate-/r*81.0%
*-un-lft-identity81.0%
associate-*l*96.6%
times-frac93.5%
Applied egg-rr93.5%
associate-/r*93.5%
frac-times99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
Final simplification97.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e+95) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (/ (/ (/ 1.0 y) z) (* z x))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+95) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = ((1.0 / y) / z) / (z * 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) <= 5d+95) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = ((1.0d0 / y) / z) / (z * 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) <= 5e+95) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = ((1.0 / y) / z) / (z * x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e+95: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = ((1.0 / y) / z) / (z * x) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+95) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(Float64(1.0 / y) / z) / Float64(z * x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e+95)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = ((1.0 / y) / z) / (z * 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], 5e+95], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+95}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{y}}{z}}{z \cdot x}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000025e95Initial program 98.9%
if 5.00000000000000025e95 < (*.f64 z z) Initial program 83.9%
distribute-lft-in83.9%
*-rgt-identity83.9%
+-commutative83.9%
associate-*r*93.0%
fma-def93.0%
Applied egg-rr93.0%
Taylor expanded in z around inf 82.2%
unpow282.2%
Simplified82.2%
associate-/r*82.4%
*-un-lft-identity82.4%
associate-*l*90.6%
times-frac94.0%
Applied egg-rr94.0%
associate-/r*95.6%
frac-times96.6%
*-un-lft-identity96.6%
Applied egg-rr96.6%
Final simplification97.9%
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 (* y x)) (/ 1.0 (* x (* z (* y z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = 1.0 / (y * x);
} 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) <= 5d-5) then
tmp = 1.0d0 / (y * x)
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) <= 5e-5) {
tmp = 1.0 / (y * x);
} 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) <= 5e-5: tmp = 1.0 / (y * x) 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) <= 5e-5) tmp = Float64(1.0 / Float64(y * x)); 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) <= 5e-5)
tmp = 1.0 / (y * x);
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], 5e-5], N[(1.0 / N[(y * x), $MachinePrecision]), $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 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.6%
associate-/r*99.7%
*-commutative99.7%
sqr-neg99.7%
+-commutative99.7%
distribute-lft1-in99.7%
*-commutative99.7%
fma-def99.7%
sqr-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 98.7%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 85.5%
associate-/r*85.4%
*-commutative85.4%
sqr-neg85.4%
+-commutative85.4%
distribute-lft1-in85.4%
*-commutative85.4%
fma-def85.4%
sqr-neg85.4%
Simplified85.4%
Taylor expanded in z around inf 84.6%
unpow284.6%
*-commutative84.6%
associate-*r*92.4%
Simplified92.4%
Final simplification95.4%
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 (* y x)) (/ 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 / (y * x);
} 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 / (y * x)
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 / (y * x);
} 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 / (y * x) 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(1.0 / Float64(y * x)); else tmp = Float64(1.0 / Float64(Float64(z * 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 / (y * x);
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[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(z * x), $MachinePrecision] * 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{1}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(z \cdot x\right) \cdot \left(y \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.6%
associate-/r*99.7%
*-commutative99.7%
sqr-neg99.7%
+-commutative99.7%
distribute-lft1-in99.7%
*-commutative99.7%
fma-def99.7%
sqr-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 98.7%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 85.5%
distribute-lft-in85.5%
*-rgt-identity85.5%
+-commutative85.5%
associate-*r*93.3%
fma-def93.3%
Applied egg-rr93.3%
Taylor expanded in z around inf 84.0%
unpow284.0%
Simplified84.0%
associate-/r*84.2%
*-un-lft-identity84.2%
associate-*l*91.2%
times-frac94.1%
Applied egg-rr94.1%
frac-times91.2%
*-un-lft-identity91.2%
associate-/l/91.0%
*-commutative91.0%
associate-*l*95.3%
Applied egg-rr95.3%
Final simplification96.9%
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 (* z z)) (* y x)) (/ 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 - (z * z)) / (y * x);
} 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 - (z * z)) / (y * x)
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 - (z * z)) / (y * x);
} 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 - (z * z)) / (y * x) 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 - Float64(z * z)) / Float64(y * x)); else tmp = Float64(1.0 / Float64(Float64(z * 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 - (z * z)) / (y * x);
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 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(z * x), $MachinePrecision] * 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{1 - z \cdot z}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(z \cdot x\right) \cdot \left(y \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.6%
associate-/r*99.7%
*-commutative99.7%
sqr-neg99.7%
+-commutative99.7%
distribute-lft1-in99.7%
*-commutative99.7%
fma-def99.7%
sqr-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 92.8%
associate-/r*92.8%
mul-1-neg92.8%
unsub-neg92.8%
associate-/r*92.8%
unpow292.8%
div-sub99.4%
Simplified99.4%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 85.5%
distribute-lft-in85.5%
*-rgt-identity85.5%
+-commutative85.5%
associate-*r*93.3%
fma-def93.3%
Applied egg-rr93.3%
Taylor expanded in z around inf 84.0%
unpow284.0%
Simplified84.0%
associate-/r*84.2%
*-un-lft-identity84.2%
associate-*l*91.2%
times-frac94.1%
Applied egg-rr94.1%
frac-times91.2%
*-un-lft-identity91.2%
associate-/l/91.0%
*-commutative91.0%
associate-*l*95.3%
Applied egg-rr95.3%
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 z) 5e-5) (/ (- 1.0 (* z z)) (* y x)) (/ (/ (/ 1.0 y) z) (* z x))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 - (z * z)) / (y * x);
} else {
tmp = ((1.0 / y) / z) / (z * 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) <= 5d-5) then
tmp = (1.0d0 - (z * z)) / (y * x)
else
tmp = ((1.0d0 / y) / z) / (z * 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) <= 5e-5) {
tmp = (1.0 - (z * z)) / (y * x);
} else {
tmp = ((1.0 / y) / z) / (z * x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-5: tmp = (1.0 - (z * z)) / (y * x) else: tmp = ((1.0 / y) / z) / (z * x) 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 - Float64(z * z)) / Float64(y * x)); else tmp = Float64(Float64(Float64(1.0 / y) / z) / Float64(z * x)); 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 - (z * z)) / (y * x);
else
tmp = ((1.0 / y) / z) / (z * 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], 5e-5], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] / N[(z * x), $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{1 - z \cdot z}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{y}}{z}}{z \cdot x}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.6%
associate-/r*99.7%
*-commutative99.7%
sqr-neg99.7%
+-commutative99.7%
distribute-lft1-in99.7%
*-commutative99.7%
fma-def99.7%
sqr-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 92.8%
associate-/r*92.8%
mul-1-neg92.8%
unsub-neg92.8%
associate-/r*92.8%
unpow292.8%
div-sub99.4%
Simplified99.4%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 85.5%
distribute-lft-in85.5%
*-rgt-identity85.5%
+-commutative85.5%
associate-*r*93.3%
fma-def93.3%
Applied egg-rr93.3%
Taylor expanded in z around inf 84.0%
unpow284.0%
Simplified84.0%
associate-/r*84.2%
*-un-lft-identity84.2%
associate-*l*91.2%
times-frac94.1%
Applied egg-rr94.1%
associate-/r*94.7%
frac-times95.6%
*-un-lft-identity95.6%
Applied egg-rr95.6%
Final simplification97.4%
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 92.3%
associate-/r*92.2%
*-commutative92.2%
sqr-neg92.2%
+-commutative92.2%
distribute-lft1-in92.2%
*-commutative92.2%
fma-def92.2%
sqr-neg92.2%
Simplified92.2%
Taylor expanded in z around 0 55.4%
Final simplification55.4%
(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 2023268
(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)))))