
(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 10 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 (* (sqrt y) (hypot 1.0 z))) (t_1 (* y (+ 1.0 (* z z)))))
(if (<= t_1 (- INFINITY))
(pow (/ (/ (sqrt (/ -1.0 x)) (sqrt (- y))) z) 2.0)
(if (<= t_1 1e+292)
(/ (/ 1.0 x) (+ y (* y (pow z 2.0))))
(* (/ 1.0 t_0) (/ (/ 1.0 x) t_0))))))assert(x < y);
double code(double x, double y, double z) {
double t_0 = sqrt(y) * hypot(1.0, z);
double t_1 = y * (1.0 + (z * z));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = pow(((sqrt((-1.0 / x)) / sqrt(-y)) / z), 2.0);
} else if (t_1 <= 1e+292) {
tmp = (1.0 / x) / (y + (y * pow(z, 2.0)));
} 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.sqrt(y) * Math.hypot(1.0, z);
double t_1 = y * (1.0 + (z * z));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = Math.pow(((Math.sqrt((-1.0 / x)) / Math.sqrt(-y)) / z), 2.0);
} else if (t_1 <= 1e+292) {
tmp = (1.0 / x) / (y + (y * Math.pow(z, 2.0)));
} 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.sqrt(y) * math.hypot(1.0, z) t_1 = y * (1.0 + (z * z)) tmp = 0 if t_1 <= -math.inf: tmp = math.pow(((math.sqrt((-1.0 / x)) / math.sqrt(-y)) / z), 2.0) elif t_1 <= 1e+292: tmp = (1.0 / x) / (y + (y * math.pow(z, 2.0))) 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(sqrt(y) * hypot(1.0, z)) t_1 = Float64(y * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(sqrt(Float64(-1.0 / x)) / sqrt(Float64(-y))) / z) ^ 2.0; elseif (t_1 <= 1e+292) tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(y * (z ^ 2.0)))); else tmp = Float64(Float64(1.0 / 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 = sqrt(y) * hypot(1.0, z);
t_1 = y * (1.0 + (z * z));
tmp = 0.0;
if (t_1 <= -Inf)
tmp = ((sqrt((-1.0 / x)) / sqrt(-y)) / z) ^ 2.0;
elseif (t_1 <= 1e+292)
tmp = (1.0 / x) / (y + (y * (z ^ 2.0)));
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[y], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[Power[N[(N[(N[Sqrt[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[(-y)], $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[t$95$1, 1e+292], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(y * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $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 := \sqrt{y} \cdot \mathsf{hypot}\left(1, z\right)\\
t_1 := y \cdot \left(1 + z \cdot z\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;{\left(\frac{\frac{\sqrt{\frac{-1}{x}}}{\sqrt{-y}}}{z}\right)}^{2}\\
\mathbf{elif}\;t_1 \leq 10^{+292}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + y \cdot {z}^{2}}\\
\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))) < -inf.0Initial program 69.0%
associate-/r*69.0%
associate-/l/69.0%
associate-/r*69.0%
associate-/l/69.0%
sqr-neg69.0%
+-commutative69.0%
sqr-neg69.0%
fma-def69.0%
Simplified69.0%
Taylor expanded in z around inf 69.0%
add-sqr-sqrt69.0%
pow269.0%
associate-/r*68.2%
sqrt-div44.4%
associate-/l/44.4%
inv-pow44.4%
sqrt-pow144.5%
metadata-eval44.5%
unpow244.5%
sqrt-prod23.0%
add-sqr-sqrt51.1%
Applied egg-rr51.1%
metadata-eval51.1%
sqrt-pow149.0%
inv-pow49.0%
associate-/r*49.0%
frac-2neg49.0%
sqrt-div46.5%
distribute-neg-frac46.5%
metadata-eval46.5%
Applied egg-rr46.5%
if -inf.0 < (*.f64 y (+.f64 1 (*.f64 z z))) < 1e292Initial program 99.7%
+-commutative99.7%
distribute-lft-in99.7%
pow299.7%
*-rgt-identity99.7%
Applied egg-rr99.7%
if 1e292 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 69.9%
*-un-lft-identity69.9%
add-sqr-sqrt69.9%
times-frac69.9%
sqrt-prod69.9%
hypot-1-def69.9%
sqrt-prod79.8%
hypot-1-def99.7%
Applied egg-rr99.7%
Final simplification90.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+145) (/ (/ 1.0 x) (+ y (* y (pow z 2.0)))) (/ (/ (/ (/ (/ 1.0 x) y) z) (sqrt z)) (sqrt z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+145) {
tmp = (1.0 / x) / (y + (y * pow(z, 2.0)));
} else {
tmp = ((((1.0 / x) / y) / z) / sqrt(z)) / sqrt(z);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 2d+145) then
tmp = (1.0d0 / x) / (y + (y * (z ** 2.0d0)))
else
tmp = ((((1.0d0 / x) / y) / z) / sqrt(z)) / sqrt(z)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+145) {
tmp = (1.0 / x) / (y + (y * Math.pow(z, 2.0)));
} else {
tmp = ((((1.0 / x) / y) / z) / Math.sqrt(z)) / Math.sqrt(z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e+145: tmp = (1.0 / x) / (y + (y * math.pow(z, 2.0))) else: tmp = ((((1.0 / x) / y) / z) / math.sqrt(z)) / math.sqrt(z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+145) tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(y * (z ^ 2.0)))); else tmp = Float64(Float64(Float64(Float64(Float64(1.0 / x) / y) / z) / sqrt(z)) / sqrt(z)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e+145)
tmp = (1.0 / x) / (y + (y * (z ^ 2.0)));
else
tmp = ((((1.0 / x) / y) / z) / sqrt(z)) / sqrt(z);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+145], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(y * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision] / z), $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision] / N[Sqrt[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+145}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + y \cdot {z}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{\frac{1}{x}}{y}}{z}}{\sqrt{z}}}{\sqrt{z}}\\
\end{array}
\end{array}
if (*.f64 z z) < 2e145Initial program 99.1%
+-commutative99.1%
distribute-lft-in99.1%
pow299.1%
*-rgt-identity99.1%
Applied egg-rr99.1%
if 2e145 < (*.f64 z z) Initial program 72.6%
associate-/r*72.6%
associate-/l/72.6%
associate-/r*72.6%
associate-/l/72.6%
sqr-neg72.6%
+-commutative72.6%
sqr-neg72.6%
fma-def72.6%
Simplified72.6%
Taylor expanded in z around inf 72.6%
add-sqr-sqrt67.4%
pow267.4%
associate-/r*66.8%
sqrt-div45.6%
associate-/l/45.6%
inv-pow45.6%
sqrt-pow145.7%
metadata-eval45.7%
unpow245.7%
sqrt-prod26.6%
add-sqr-sqrt52.4%
Applied egg-rr52.4%
unpow252.4%
add-sqr-sqrt34.9%
associate-*l*34.9%
sqrt-div26.6%
sqrt-pow126.6%
metadata-eval26.6%
sqrt-div26.6%
sqrt-pow126.6%
metadata-eval26.6%
Applied egg-rr26.6%
associate-*l/26.6%
associate-*l/26.6%
associate-*r/26.5%
associate-*l*26.5%
pow-sqr26.6%
metadata-eval26.6%
associate-*r/25.7%
pow-sqr43.2%
metadata-eval43.2%
unpow-143.2%
associate-/r*43.2%
Simplified43.2%
Final simplification77.9%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y 6e-297)
(/ (/ 1.0 x) (* y (+ 1.0 (* z z))))
(if (<= y 1e-41)
(/ (/ 1.0 x) (+ y (pow (* z (sqrt y)) 2.0)))
(/ (/ 1.0 y) (* x (fma z z 1.0))))))assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (y <= 6e-297) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else if (y <= 1e-41) {
tmp = (1.0 / x) / (y + pow((z * sqrt(y)), 2.0));
} else {
tmp = (1.0 / y) / (x * fma(z, z, 1.0));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (y <= 6e-297) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); elseif (y <= 1e-41) tmp = Float64(Float64(1.0 / x) / Float64(y + (Float64(z * sqrt(y)) ^ 2.0))); else tmp = Float64(Float64(1.0 / y) / Float64(x * fma(z, z, 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[y, 6e-297], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e-41], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[Power[N[(z * N[Sqrt[y], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{-297}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{elif}\;y \leq 10^{-41}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + {\left(z \cdot \sqrt{y}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}\\
\end{array}
\end{array}
if y < 5.9999999999999999e-297Initial program 89.7%
if 5.9999999999999999e-297 < y < 1.00000000000000001e-41Initial program 87.9%
+-commutative87.9%
distribute-lft-in87.9%
pow287.9%
*-rgt-identity87.9%
Applied egg-rr87.9%
add-sqr-sqrt87.8%
pow287.8%
*-commutative87.8%
sqrt-prod87.9%
unpow287.9%
sqrt-prod45.0%
add-sqr-sqrt92.6%
Applied egg-rr92.6%
if 1.00000000000000001e-41 < y Initial program 88.6%
associate-/r*86.6%
associate-/l/88.6%
associate-/r*88.6%
associate-/l/94.2%
sqr-neg94.2%
+-commutative94.2%
sqr-neg94.2%
fma-def94.2%
Simplified94.2%
Final simplification91.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 y) (* x (fma z z 1.0))))
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / y) / (x * fma(z, z, 1.0));
}
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / y) / Float64(x * fma(z, z, 1.0))) end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}
\end{array}
Initial program 89.1%
associate-/r*88.1%
associate-/l/89.1%
associate-/r*89.0%
associate-/l/88.6%
sqr-neg88.6%
+-commutative88.6%
sqr-neg88.6%
fma-def88.6%
Simplified88.6%
Final simplification88.6%
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 2e+305)
(/ (/ 1.0 x) t_0)
(* (/ 1.0 (* y x)) (* (/ 1.0 z) (/ 1.0 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 <= 2e+305) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / (y * x)) * ((1.0 / z) * (1.0 / z));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 + (z * z))
if (t_0 <= 2d+305) then
tmp = (1.0d0 / x) / t_0
else
tmp = (1.0d0 / (y * x)) * ((1.0d0 / z) * (1.0d0 / z))
end if
code = tmp
end function
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 <= 2e+305) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / (y * x)) * ((1.0 / z) * (1.0 / 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 <= 2e+305: tmp = (1.0 / x) / t_0 else: tmp = (1.0 / (y * x)) * ((1.0 / z) * (1.0 / 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 <= 2e+305) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(1.0 / Float64(y * x)) * Float64(Float64(1.0 / z) * Float64(1.0 / 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 <= 2e+305)
tmp = (1.0 / x) / t_0;
else
tmp = (1.0 / (y * x)) * ((1.0 / z) * (1.0 / z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+305], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / z), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $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 2 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot x} \cdot \left(\frac{1}{z} \cdot \frac{1}{z}\right)\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.9999999999999999e305Initial program 93.5%
if 1.9999999999999999e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 67.1%
associate-/r*67.1%
associate-/l/67.1%
associate-/r*67.1%
associate-/l/78.0%
sqr-neg78.0%
+-commutative78.0%
sqr-neg78.0%
fma-def78.0%
Simplified78.0%
Taylor expanded in z around inf 78.0%
add-sqr-sqrt73.3%
pow273.3%
associate-/r*73.2%
sqrt-div49.3%
associate-/l/49.3%
inv-pow49.3%
sqrt-pow149.3%
metadata-eval49.3%
unpow249.3%
sqrt-prod32.4%
add-sqr-sqrt58.0%
Applied egg-rr58.0%
unpow258.0%
div-inv58.0%
div-inv58.0%
swap-sqr49.4%
pow-prod-up80.0%
metadata-eval80.0%
inv-pow80.0%
Applied egg-rr80.0%
Final simplification91.2%
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 2e+305) (/ (/ 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 <= 2e+305) {
tmp = (1.0 / x) / t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 + (z * z))
if (t_0 <= 2d+305) then
tmp = (1.0d0 / x) / t_0
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 t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 2e+305) {
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 <= 2e+305: 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 <= 2e+305) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(-1.0 / Float64(y * x)) / Float64(z * Float64(-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 <= 2e+305)
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, 2e+305], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(-1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(z * (-z)), $MachinePrecision]), $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 2 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{y \cdot x}}{z \cdot \left(-z\right)}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.9999999999999999e305Initial program 93.5%
if 1.9999999999999999e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 67.1%
associate-/r*67.1%
associate-/l/67.1%
associate-/r*67.1%
associate-/l/78.0%
sqr-neg78.0%
+-commutative78.0%
sqr-neg78.0%
fma-def78.0%
Simplified78.0%
Taylor expanded in z around inf 78.0%
add-sqr-sqrt73.3%
pow273.3%
associate-/r*73.2%
sqrt-div49.3%
associate-/l/49.3%
inv-pow49.3%
sqrt-pow149.3%
metadata-eval49.3%
unpow249.3%
sqrt-prod32.4%
add-sqr-sqrt58.0%
Applied egg-rr58.0%
unpow258.0%
frac-2neg58.0%
frac-times49.4%
distribute-lft-neg-in49.4%
pow-prod-up77.9%
metadata-eval77.9%
inv-pow77.9%
clear-num77.9%
distribute-neg-frac77.9%
metadata-eval77.9%
/-rgt-identity77.9%
Applied egg-rr77.9%
Final simplification90.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 1.0) (/ (/ 1.0 y) x) (/ (/ -1.0 (* y x)) (* z (- z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / y) / x;
} else {
tmp = (-1.0 / (y * x)) / (z * -z);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 1.0d0) then
tmp = (1.0d0 / y) / x
else
tmp = ((-1.0d0) / (y * x)) / (z * -z)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / y) / x;
} else {
tmp = (-1.0 / (y * x)) / (z * -z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 1.0: tmp = (1.0 / y) / x else: tmp = (-1.0 / (y * x)) / (z * -z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 1.0) tmp = Float64(Float64(1.0 / y) / x); else tmp = Float64(Float64(-1.0 / Float64(y * x)) / Float64(z * Float64(-z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= 1.0)
tmp = (1.0 / y) / x;
else
tmp = (-1.0 / (y * x)) / (z * -z);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, 1.0], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(N[(-1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(z * (-z)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{y \cdot x}}{z \cdot \left(-z\right)}\\
\end{array}
\end{array}
if z < 1Initial program 92.1%
Taylor expanded in z around 0 66.4%
associate-/l/67.2%
Simplified67.2%
if 1 < z Initial program 80.9%
associate-/r*80.5%
associate-/l/81.0%
associate-/r*80.9%
associate-/l/79.6%
sqr-neg79.6%
+-commutative79.6%
sqr-neg79.6%
fma-def79.6%
Simplified79.6%
Taylor expanded in z around inf 78.5%
add-sqr-sqrt60.0%
pow260.0%
associate-/r*61.0%
sqrt-div43.5%
associate-/l/43.5%
inv-pow43.5%
sqrt-pow143.5%
metadata-eval43.5%
unpow243.5%
sqrt-prod51.4%
add-sqr-sqrt51.4%
Applied egg-rr51.4%
unpow251.4%
frac-2neg51.4%
frac-times43.6%
distribute-lft-neg-in43.6%
pow-prod-up82.5%
metadata-eval82.5%
inv-pow82.5%
clear-num82.5%
distribute-neg-frac82.5%
metadata-eval82.5%
/-rgt-identity82.5%
Applied egg-rr82.5%
Final simplification71.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 89.1%
Taylor expanded in z around 0 52.6%
Final simplification52.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 x) y))
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / x) / y;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / y
end function
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / x) / y;
}
[x, y] = sort([x, y]) def code(x, y, z): return (1.0 / x) / y
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / x) / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / x) / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{x}}{y}
\end{array}
Initial program 89.1%
Taylor expanded in z around 0 53.2%
Final simplification53.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 y) x))
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / y) / x;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / y) / x
end function
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / y) / x;
}
[x, y] = sort([x, y]) def code(x, y, z): return (1.0 / y) / x
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / y) / x) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / y) / x;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{y}}{x}
\end{array}
Initial program 89.1%
Taylor expanded in z around 0 52.6%
associate-/l/53.2%
Simplified53.2%
Final simplification53.2%
(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 2023318
(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)))))