
(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
(let* ((t_0 (* (hypot 1.0 z) (sqrt y))))
(if (<= (* y (+ 1.0 (* z z))) 2e+305)
(/ (/ 1.0 x) (fma (* y z) z y))
(* (/ 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))) <= 2e+305) {
tmp = (1.0 / x) / fma((y * z), z, y);
} 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))) <= 2e+305) tmp = Float64(Float64(1.0 / x) / fma(Float64(y * z), z, y)); else tmp = Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / x) / t_0)); end return 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], 2e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $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 2 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{\frac{1}{x}}{t_0}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.9999999999999999e305Initial program 96.2%
distribute-lft-in96.2%
*-rgt-identity96.2%
+-commutative96.2%
associate-*r*98.5%
fma-def98.5%
Applied egg-rr98.5%
if 1.9999999999999999e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 66.1%
associate-/r*66.1%
*-commutative66.1%
sqr-neg66.1%
+-commutative66.1%
distribute-lft1-in66.1%
*-commutative66.1%
fma-def66.1%
sqr-neg66.1%
Simplified66.1%
associate-/r*66.1%
*-un-lft-identity66.1%
add-sqr-sqrt66.1%
times-frac66.1%
fma-udef66.1%
*-rgt-identity66.1%
distribute-lft-in66.1%
+-commutative66.1%
+-commutative66.1%
fma-udef66.1%
*-commutative66.1%
sqrt-prod66.1%
fma-udef66.1%
+-commutative66.1%
hypot-1-def66.1%
fma-udef66.1%
*-rgt-identity66.1%
distribute-lft-in66.1%
+-commutative66.1%
Applied egg-rr99.5%
Final simplification98.6%
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+305) (/ (/ 1.0 x) (fma (* y z) z y)) (* (/ 1.0 y) (pow (* z (* z x)) -1.0))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 4e+305) {
tmp = (1.0 / x) / fma((y * z), z, y);
} else {
tmp = (1.0 / y) * pow((z * (z * x)), -1.0);
}
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+305) tmp = Float64(Float64(1.0 / x) / fma(Float64(y * z), z, y)); else tmp = Float64(Float64(1.0 / y) * (Float64(z * Float64(z * x)) ^ -1.0)); 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[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[Power[N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision], -1.0], $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^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot {\left(z \cdot \left(z \cdot x\right)\right)}^{-1}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 3.9999999999999998e305Initial program 96.3%
distribute-lft-in96.3%
*-rgt-identity96.3%
+-commutative96.3%
associate-*r*98.5%
fma-def98.5%
Applied egg-rr98.5%
if 3.9999999999999998e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 65.3%
associate-/r*65.3%
*-commutative65.3%
sqr-neg65.3%
+-commutative65.3%
distribute-lft1-in65.3%
*-commutative65.3%
fma-def65.3%
sqr-neg65.3%
Simplified65.3%
Taylor expanded in z around inf 65.3%
unpow265.3%
associate-*r*69.6%
*-commutative69.6%
Simplified69.6%
inv-pow69.6%
associate-*l*70.0%
unpow-prod-down71.4%
inv-pow71.4%
associate-*r*88.0%
Applied egg-rr88.0%
Final simplification96.8%
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+305) (/ (/ 1.0 x) (fma (* y z) z y)) (/ (/ (/ 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+305) {
tmp = (1.0 / x) / fma((y * z), z, y);
} 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+305) tmp = Float64(Float64(1.0 / x) / fma(Float64(y * z), z, y)); else tmp = Float64(Float64(Float64(1.0 / y) / z) / Float64(z * x)); 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[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $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^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{y}}{z}}{z \cdot x}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 3.9999999999999998e305Initial program 96.3%
distribute-lft-in96.3%
*-rgt-identity96.3%
+-commutative96.3%
associate-*r*98.5%
fma-def98.5%
Applied egg-rr98.5%
if 3.9999999999999998e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 65.3%
associate-/r*65.3%
*-commutative65.3%
sqr-neg65.3%
+-commutative65.3%
distribute-lft1-in65.3%
*-commutative65.3%
fma-def65.3%
sqr-neg65.3%
Simplified65.3%
Taylor expanded in z around inf 65.3%
unpow265.3%
associate-*r*69.6%
*-commutative69.6%
Simplified69.6%
associate-/r*71.0%
associate-/l/71.1%
un-div-inv71.1%
*-un-lft-identity71.1%
times-frac90.2%
frac-times90.2%
metadata-eval90.2%
Applied egg-rr90.2%
associate-/l/90.2%
frac-times88.8%
metadata-eval88.8%
associate-*r*96.8%
associate-*l*86.5%
associate-/l/88.0%
associate-/r*94.0%
*-commutative94.0%
Applied egg-rr94.0%
Final simplification97.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+62) (/ (/ 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) <= 4e+62) {
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) <= 4d+62) 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) <= 4e+62) {
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) <= 4e+62: 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) <= 4e+62) 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) <= 4e+62)
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], 4e+62], 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 4 \cdot 10^{+62}:\\
\;\;\;\;\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) < 4.00000000000000014e62Initial program 99.7%
if 4.00000000000000014e62 < (*.f64 z z) Initial program 80.0%
associate-/r*80.0%
*-commutative80.0%
sqr-neg80.0%
+-commutative80.0%
distribute-lft1-in80.0%
*-commutative80.0%
fma-def80.0%
sqr-neg80.0%
Simplified80.0%
Taylor expanded in z around inf 80.0%
unpow280.0%
associate-*r*76.7%
*-commutative76.7%
Simplified76.7%
associate-/r*75.7%
associate-/l/75.8%
un-div-inv75.7%
*-un-lft-identity75.7%
times-frac83.0%
frac-times83.0%
metadata-eval83.0%
Applied egg-rr83.0%
associate-/l/84.5%
frac-times84.0%
metadata-eval84.0%
associate-*r*96.0%
associate-*l*89.7%
associate-/l/90.2%
associate-/r*95.9%
*-commutative95.9%
Applied egg-rr95.9%
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) 0.2) (/ (/ 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) <= 0.2) {
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) <= 0.2d0) 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) <= 0.2) {
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) <= 0.2: 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) <= 0.2) 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) <= 0.2)
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], 0.2], 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 0.2:\\
\;\;\;\;\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) < 0.20000000000000001Initial program 99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
+-commutative99.7%
associate-*r*99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 97.8%
associate-/r*99.1%
Simplified99.1%
if 0.20000000000000001 < (*.f64 z z) Initial program 83.0%
associate-/r*83.0%
*-commutative83.0%
sqr-neg83.0%
+-commutative83.0%
distribute-lft1-in83.0%
*-commutative83.0%
fma-def83.0%
sqr-neg83.0%
Simplified83.0%
Taylor expanded in z around inf 82.5%
unpow282.5%
Simplified82.5%
Taylor expanded in y around 0 82.5%
unpow282.5%
*-commutative82.5%
associate-*l*91.5%
*-commutative91.5%
Simplified91.5%
Final simplification95.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 0.2) (/ (/ 1.0 x) y) (/ 1.0 (* y (* z (* z x))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.2) {
tmp = (1.0 / x) / y;
} 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) <= 0.2d0) then
tmp = (1.0d0 / x) / y
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) <= 0.2) {
tmp = (1.0 / x) / y;
} 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) <= 0.2: tmp = (1.0 / x) / y 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) <= 0.2) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(y * Float64(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) <= 0.2)
tmp = (1.0 / x) / y;
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], 0.2], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(y * N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.2:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.20000000000000001Initial program 99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
+-commutative99.7%
associate-*r*99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 97.8%
associate-/r*99.1%
Simplified99.1%
if 0.20000000000000001 < (*.f64 z z) Initial program 83.0%
associate-/r*83.0%
*-commutative83.0%
sqr-neg83.0%
+-commutative83.0%
distribute-lft1-in83.0%
*-commutative83.0%
fma-def83.0%
sqr-neg83.0%
Simplified83.0%
Taylor expanded in z around inf 82.5%
*-commutative82.5%
unpow282.5%
associate-*l*82.5%
associate-*l*90.7%
Simplified90.7%
Final simplification94.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 0.2) (/ (/ 1.0 x) y) (/ (/ 1.0 (* y z)) (* z x))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.2) {
tmp = (1.0 / x) / y;
} 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) <= 0.2d0) then
tmp = (1.0d0 / x) / y
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) <= 0.2) {
tmp = (1.0 / x) / y;
} 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) <= 0.2: tmp = (1.0 / x) / y 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) <= 0.2) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(1.0 / Float64(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) <= 0.2)
tmp = (1.0 / x) / y;
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], 0.2], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.2:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot z}}{z \cdot x}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.20000000000000001Initial program 99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
+-commutative99.7%
associate-*r*99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 97.8%
associate-/r*99.1%
Simplified99.1%
if 0.20000000000000001 < (*.f64 z z) Initial program 83.0%
associate-/r*83.0%
*-commutative83.0%
sqr-neg83.0%
+-commutative83.0%
distribute-lft1-in83.0%
*-commutative83.0%
fma-def83.0%
sqr-neg83.0%
Simplified83.0%
Taylor expanded in z around inf 82.5%
unpow282.5%
associate-*r*79.6%
*-commutative79.6%
Simplified79.6%
associate-/r*78.8%
associate-/l/78.8%
un-div-inv78.8%
*-un-lft-identity78.8%
times-frac84.9%
frac-times85.0%
metadata-eval85.0%
Applied egg-rr85.0%
associate-/l/86.3%
frac-times85.8%
metadata-eval85.8%
associate-*r*96.0%
associate-*l*90.7%
*-commutative90.7%
associate-*r*95.9%
associate-/r*95.9%
*-commutative95.9%
Applied egg-rr95.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) 0.2) (/ (/ 1.0 x) y) (/ (/ (/ 1.0 y) z) (* z x))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.2) {
tmp = (1.0 / x) / y;
} 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) <= 0.2d0) then
tmp = (1.0d0 / x) / y
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) <= 0.2) {
tmp = (1.0 / x) / y;
} 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) <= 0.2: tmp = (1.0 / x) / y 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) <= 0.2) tmp = Float64(Float64(1.0 / x) / y); 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) <= 0.2)
tmp = (1.0 / x) / y;
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], 0.2], N[(N[(1.0 / x), $MachinePrecision] / y), $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 0.2:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{y}}{z}}{z \cdot x}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.20000000000000001Initial program 99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
+-commutative99.7%
associate-*r*99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 97.8%
associate-/r*99.1%
Simplified99.1%
if 0.20000000000000001 < (*.f64 z z) Initial program 83.0%
associate-/r*83.0%
*-commutative83.0%
sqr-neg83.0%
+-commutative83.0%
distribute-lft1-in83.0%
*-commutative83.0%
fma-def83.0%
sqr-neg83.0%
Simplified83.0%
Taylor expanded in z around inf 82.5%
unpow282.5%
associate-*r*79.6%
*-commutative79.6%
Simplified79.6%
associate-/r*78.8%
associate-/l/78.8%
un-div-inv78.8%
*-un-lft-identity78.8%
times-frac84.9%
frac-times85.0%
metadata-eval85.0%
Applied egg-rr85.0%
associate-/l/86.3%
frac-times85.8%
metadata-eval85.8%
associate-*r*96.0%
associate-*l*90.7%
associate-/l/91.2%
associate-/r*96.0%
*-commutative96.0%
Applied egg-rr96.0%
Final simplification97.6%
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 (* y (* z 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 * (y * (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 <= 1.0d0) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (x * (y * (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 <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (y * (z * 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 * (y * (z * 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(y * Float64(z * 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 * (y * (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[z, 1.0], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(x * N[(y * N[(z * 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(y \cdot \left(z \cdot z\right)\right)}\\
\end{array}
\end{array}
if z < 1Initial program 93.3%
distribute-lft-in93.3%
*-rgt-identity93.3%
+-commutative93.3%
associate-*r*96.7%
fma-def96.7%
Applied egg-rr96.7%
Taylor expanded in z around 0 70.0%
associate-/r*70.5%
Simplified70.5%
if 1 < z Initial program 84.5%
associate-/r*84.6%
*-commutative84.6%
sqr-neg84.6%
+-commutative84.6%
distribute-lft1-in84.6%
*-commutative84.6%
fma-def84.6%
sqr-neg84.6%
Simplified84.6%
Taylor expanded in z around inf 83.5%
unpow283.5%
Simplified83.5%
Final simplification73.3%
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 91.4%
associate-/r*90.7%
*-commutative90.7%
sqr-neg90.7%
+-commutative90.7%
distribute-lft1-in90.7%
*-commutative90.7%
fma-def90.7%
sqr-neg90.7%
Simplified90.7%
Taylor expanded in z around 0 58.7%
*-commutative58.7%
Simplified58.7%
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(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 91.4%
distribute-lft-in91.4%
*-rgt-identity91.4%
+-commutative91.4%
associate-*r*95.9%
fma-def95.9%
Applied egg-rr95.9%
Taylor expanded in z around 0 58.7%
associate-/r*58.8%
Simplified58.8%
Final simplification58.8%
(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 2023287
(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)))))