
(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 (* y (+ 1.0 (* z z)))))
(if (<= t_0 1e-210)
(/ (/ 1.0 x) t_0)
(/ (/ (pow y -0.5) (hypot 1.0 z)) (* x (* (hypot 1.0 z) (sqrt y)))))))assert(x < y);
double code(double x, double y, double z) {
double t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e-210) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (pow(y, -0.5) / hypot(1.0, z)) / (x * (hypot(1.0, z) * sqrt(y)));
}
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 <= 1e-210) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (Math.pow(y, -0.5) / Math.hypot(1.0, z)) / (x * (Math.hypot(1.0, z) * Math.sqrt(y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): t_0 = y * (1.0 + (z * z)) tmp = 0 if t_0 <= 1e-210: tmp = (1.0 / x) / t_0 else: tmp = (math.pow(y, -0.5) / math.hypot(1.0, z)) / (x * (math.hypot(1.0, z) * math.sqrt(y))) 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 <= 1e-210) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64((y ^ -0.5) / hypot(1.0, z)) / Float64(x * Float64(hypot(1.0, z) * sqrt(y)))); 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 <= 1e-210)
tmp = (1.0 / x) / t_0;
else
tmp = ((y ^ -0.5) / hypot(1.0, z)) / (x * (hypot(1.0, z) * sqrt(y)));
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, 1e-210], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Power[y, -0.5], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $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 10^{-210}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{y}^{-0.5}}{\mathsf{hypot}\left(1, z\right)}}{x \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right)}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1e-210Initial program 91.4%
if 1e-210 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 86.5%
*-un-lft-identity86.5%
times-frac88.0%
associate-/r*87.9%
+-commutative87.9%
fma-udef87.9%
*-commutative87.9%
fma-udef87.9%
+-commutative87.9%
*-commutative87.9%
+-commutative87.9%
fma-udef87.9%
Applied egg-rr87.9%
associate-*l/88.0%
*-commutative88.0%
times-frac86.4%
associate-/l/86.5%
metadata-eval86.5%
fma-udef86.5%
unpow286.5%
+-commutative86.5%
unpow286.5%
metadata-eval86.5%
rem-square-sqrt86.4%
hypot-udef86.5%
hypot-udef86.5%
add-sqr-sqrt86.2%
swap-sqr91.4%
*-commutative91.4%
*-commutative91.4%
frac-times91.5%
Applied egg-rr99.7%
Final simplification95.5%
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 1e+301)
(/ (/ 1.0 x) t_0)
(*
(* (sqrt (/ 1.0 y)) (/ 1.0 z))
(/ (/ 1.0 x) (* (hypot 1.0 z) (sqrt y)))))))assert(x < y);
double code(double x, double y, double z) {
double t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (sqrt((1.0 / y)) * (1.0 / z)) * ((1.0 / x) / (hypot(1.0, z) * sqrt(y)));
}
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 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (Math.sqrt((1.0 / y)) * (1.0 / z)) * ((1.0 / x) / (Math.hypot(1.0, z) * Math.sqrt(y)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): t_0 = y * (1.0 + (z * z)) tmp = 0 if t_0 <= 1e+301: tmp = (1.0 / x) / t_0 else: tmp = (math.sqrt((1.0 / y)) * (1.0 / z)) * ((1.0 / x) / (math.hypot(1.0, z) * math.sqrt(y))) 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 <= 1e+301) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(sqrt(Float64(1.0 / y)) * Float64(1.0 / z)) * Float64(Float64(1.0 / x) / Float64(hypot(1.0, z) * sqrt(y)))); 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 <= 1e+301)
tmp = (1.0 / x) / t_0;
else
tmp = (sqrt((1.0 / y)) * (1.0 / z)) * ((1.0 / x) / (hypot(1.0, z) * sqrt(y)));
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, 1e+301], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $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 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{y}} \cdot \frac{1}{z}\right) \cdot \frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.00000000000000005e301Initial program 94.6%
if 1.00000000000000005e301 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 63.0%
*-un-lft-identity63.0%
add-sqr-sqrt63.0%
times-frac63.0%
sqrt-prod63.0%
hypot-1-def63.0%
sqrt-prod73.2%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in z around inf 89.4%
Final simplification93.7%
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 1e+301)
(/ (/ 1.0 x) t_0)
(* (/ (/ 1.0 x) (* (hypot 1.0 z) (sqrt y))) (/ (sqrt (/ 1.0 y)) 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 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = ((1.0 / x) / (hypot(1.0, z) * sqrt(y))) * (sqrt((1.0 / y)) / 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 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = ((1.0 / x) / (Math.hypot(1.0, z) * Math.sqrt(y))) * (Math.sqrt((1.0 / y)) / 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 <= 1e+301: tmp = (1.0 / x) / t_0 else: tmp = ((1.0 / x) / (math.hypot(1.0, z) * math.sqrt(y))) * (math.sqrt((1.0 / y)) / 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 <= 1e+301) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(Float64(1.0 / x) / Float64(hypot(1.0, z) * sqrt(y))) * Float64(sqrt(Float64(1.0 / y)) / 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 <= 1e+301)
tmp = (1.0 / x) / t_0;
else
tmp = ((1.0 / x) / (hypot(1.0, z) * sqrt(y))) * (sqrt((1.0 / 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_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+301], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] / 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 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}} \cdot \frac{\sqrt{\frac{1}{y}}}{z}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.00000000000000005e301Initial program 94.6%
if 1.00000000000000005e301 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 63.0%
*-un-lft-identity63.0%
add-sqr-sqrt63.0%
times-frac63.0%
sqrt-prod63.0%
hypot-1-def63.0%
sqrt-prod73.2%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in z around inf 89.4%
associate-*r/89.4%
*-rgt-identity89.4%
Simplified89.4%
Final simplification93.7%
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 1e+301)
(/ (/ 1.0 x) t_0)
(* (/ (/ 1.0 (* z x)) (sqrt y)) (/ (/ 1.0 z) (sqrt y))))))assert(x < y);
double code(double x, double y, double z) {
double t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = ((1.0 / (z * x)) / sqrt(y)) * ((1.0 / z) / sqrt(y));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 + (z * z))
if (t_0 <= 1d+301) then
tmp = (1.0d0 / x) / t_0
else
tmp = ((1.0d0 / (z * x)) / sqrt(y)) * ((1.0d0 / z) / sqrt(y))
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 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = ((1.0 / (z * x)) / Math.sqrt(y)) * ((1.0 / z) / Math.sqrt(y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): t_0 = y * (1.0 + (z * z)) tmp = 0 if t_0 <= 1e+301: tmp = (1.0 / x) / t_0 else: tmp = ((1.0 / (z * x)) / math.sqrt(y)) * ((1.0 / z) / math.sqrt(y)) 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 <= 1e+301) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(Float64(1.0 / Float64(z * x)) / sqrt(y)) * Float64(Float64(1.0 / z) / sqrt(y))); 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 <= 1e+301)
tmp = (1.0 / x) / t_0;
else
tmp = ((1.0 / (z * x)) / sqrt(y)) * ((1.0 / z) / sqrt(y));
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, 1e+301], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(1.0 / N[(z * x), $MachinePrecision]), $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / z), $MachinePrecision] / N[Sqrt[y], $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 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z \cdot x}}{\sqrt{y}} \cdot \frac{\frac{1}{z}}{\sqrt{y}}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.00000000000000005e301Initial program 94.6%
if 1.00000000000000005e301 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 63.0%
associate-/r*63.0%
associate-/l/63.0%
associate-/r*63.0%
associate-/l/73.2%
sqr-neg73.2%
+-commutative73.2%
sqr-neg73.2%
fma-def73.2%
Simplified73.2%
Taylor expanded in z around inf 73.2%
*-commutative73.2%
Simplified73.2%
add-sqr-sqrt39.2%
pow239.2%
sqrt-prod39.2%
unpow239.2%
sqrt-prod23.8%
add-sqr-sqrt43.4%
Applied egg-rr43.4%
associate-/l/43.4%
associate-/r*43.3%
metadata-eval43.3%
unpow243.3%
*-commutative43.3%
associate-*r*43.3%
associate-*r*43.4%
add-sqr-sqrt87.7%
frac-times88.2%
associate-/l/88.2%
add-sqr-sqrt88.2%
times-frac99.5%
associate-/l/99.5%
Applied egg-rr99.5%
Final simplification95.5%
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 1e+301) (/ (/ 1.0 x) t_0) (/ (/ 1.0 (* y (* z x))) 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 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 + (z * z))
if (t_0 <= 1d+301) then
tmp = (1.0d0 / x) / t_0
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 t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / (y * (z * x))) / 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 <= 1e+301: tmp = (1.0 / x) / t_0 else: tmp = (1.0 / (y * (z * x))) / 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 <= 1e+301) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * x))) / 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 <= 1e+301)
tmp = (1.0 / x) / t_0;
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_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+301], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $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 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.00000000000000005e301Initial program 94.6%
if 1.00000000000000005e301 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 63.0%
*-un-lft-identity63.0%
times-frac73.2%
associate-/r*73.2%
+-commutative73.2%
fma-udef73.2%
*-commutative73.2%
fma-udef73.2%
+-commutative73.2%
*-commutative73.2%
+-commutative73.2%
fma-udef73.2%
Applied egg-rr73.2%
Taylor expanded in z around inf 73.2%
associate-/r*73.2%
Simplified73.2%
*-un-lft-identity73.2%
unpow273.2%
times-frac88.2%
Applied egg-rr88.2%
associate-*l*97.6%
associate-*l/97.7%
*-un-lft-identity97.7%
associate-/l/97.8%
frac-times97.8%
metadata-eval97.8%
Applied egg-rr97.8%
Final simplification95.2%
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)
(if (<= z 2.6e+162)
(/ (/ (/ 1.0 (* y x)) z) z)
(/ (/ 1.0 (* z x)) (* y z)))))assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / y) / x;
} else if (z <= 2.6e+162) {
tmp = ((1.0 / (y * x)) / z) / z;
} 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 <= 1.0d0) then
tmp = (1.0d0 / y) / x
else if (z <= 2.6d+162) then
tmp = ((1.0d0 / (y * x)) / z) / z
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 <= 1.0) {
tmp = (1.0 / y) / x;
} else if (z <= 2.6e+162) {
tmp = ((1.0 / (y * x)) / z) / z;
} else {
tmp = (1.0 / (z * x)) / (y * z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 1.0: tmp = (1.0 / y) / x elif z <= 2.6e+162: tmp = ((1.0 / (y * x)) / z) / z else: tmp = (1.0 / (z * x)) / (y * 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); elseif (z <= 2.6e+162) tmp = Float64(Float64(Float64(1.0 / Float64(y * x)) / z) / z); else tmp = Float64(Float64(1.0 / 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 <= 1.0)
tmp = (1.0 / y) / x;
elseif (z <= 2.6e+162)
tmp = ((1.0 / (y * x)) / z) / z;
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[z, 1.0], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[z, 2.6e+162], N[(N[(N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / z), $MachinePrecision], N[(N[(1.0 / N[(z * x), $MachinePrecision]), $MachinePrecision] / N[(y * 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{elif}\;z \leq 2.6 \cdot 10^{+162}:\\
\;\;\;\;\frac{\frac{\frac{1}{y \cdot x}}{z}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z \cdot x}}{y \cdot z}\\
\end{array}
\end{array}
if z < 1Initial program 94.2%
associate-/r*93.9%
associate-/l/94.2%
associate-/r*94.3%
associate-/l/92.8%
sqr-neg92.8%
+-commutative92.8%
sqr-neg92.8%
fma-def92.8%
Simplified92.8%
Taylor expanded in z around 0 65.9%
if 1 < z < 2.6e162Initial program 79.2%
*-un-lft-identity79.2%
times-frac93.6%
associate-/r*93.6%
+-commutative93.6%
fma-udef93.6%
*-commutative93.6%
fma-udef93.6%
+-commutative93.6%
*-commutative93.6%
+-commutative93.6%
fma-udef93.6%
Applied egg-rr93.6%
Taylor expanded in z around inf 91.3%
associate-/r*91.3%
Simplified91.3%
associate-*l/91.4%
div-inv91.6%
unpow291.6%
associate-/r*94.4%
associate-/l/94.3%
Applied egg-rr94.3%
if 2.6e162 < z Initial program 67.0%
*-un-lft-identity67.0%
times-frac67.0%
associate-/r*67.0%
+-commutative67.0%
fma-udef67.0%
*-commutative67.0%
fma-udef67.0%
+-commutative67.0%
*-commutative67.0%
+-commutative67.0%
fma-udef67.0%
Applied egg-rr67.0%
Taylor expanded in z around inf 67.0%
associate-/r*67.0%
Simplified67.0%
*-un-lft-identity67.0%
unpow267.0%
times-frac85.1%
Applied egg-rr85.1%
*-commutative85.1%
associate-*l/85.2%
*-un-lft-identity85.2%
frac-times99.8%
*-un-lft-identity99.8%
associate-/l/100.0%
Applied egg-rr100.0%
Final simplification73.7%
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) (* z (* z x)))))
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) / (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 <= 1.0d0) then
tmp = (1.0d0 / 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 <= 1.0) {
tmp = (1.0 / 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 <= 1.0: tmp = (1.0 / 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 (z <= 1.0) tmp = Float64(Float64(1.0 / y) / x); else tmp = Float64(Float64(1.0 / 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 <= 1.0)
tmp = (1.0 / 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[z, 1.0], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if z < 1Initial program 94.2%
associate-/r*93.9%
associate-/l/94.2%
associate-/r*94.3%
associate-/l/92.8%
sqr-neg92.8%
+-commutative92.8%
sqr-neg92.8%
fma-def92.8%
Simplified92.8%
Taylor expanded in z around 0 65.9%
if 1 < z Initial program 73.1%
associate-/r*72.8%
associate-/l/73.1%
associate-/r*73.2%
associate-/l/80.3%
sqr-neg80.3%
+-commutative80.3%
sqr-neg80.3%
fma-def80.3%
Simplified80.3%
Taylor expanded in z around inf 79.2%
*-commutative79.2%
Simplified79.2%
add-sqr-sqrt38.1%
pow238.1%
sqrt-prod38.1%
unpow238.1%
sqrt-prod45.3%
add-sqr-sqrt45.5%
Applied egg-rr45.5%
unpow245.5%
*-commutative45.5%
associate-*r*45.4%
associate-*r*45.4%
add-sqr-sqrt88.3%
Applied egg-rr88.3%
Final simplification71.5%
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 (* z x)) (* y 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 / (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 <= 1.0d0) 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 <= 1.0) {
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 <= 1.0: 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 (z <= 1.0) tmp = Float64(Float64(1.0 / y) / x); else tmp = Float64(Float64(1.0 / 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 <= 1.0)
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[z, 1.0], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / N[(z * x), $MachinePrecision]), $MachinePrecision] / N[(y * 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}{z \cdot x}}{y \cdot z}\\
\end{array}
\end{array}
if z < 1Initial program 94.2%
associate-/r*93.9%
associate-/l/94.2%
associate-/r*94.3%
associate-/l/92.8%
sqr-neg92.8%
+-commutative92.8%
sqr-neg92.8%
fma-def92.8%
Simplified92.8%
Taylor expanded in z around 0 65.9%
if 1 < z Initial program 73.1%
*-un-lft-identity73.1%
times-frac80.3%
associate-/r*80.3%
+-commutative80.3%
fma-udef80.3%
*-commutative80.3%
fma-udef80.3%
+-commutative80.3%
*-commutative80.3%
+-commutative80.3%
fma-udef80.3%
Applied egg-rr80.3%
Taylor expanded in z around inf 79.2%
associate-/r*79.2%
Simplified79.2%
*-un-lft-identity79.2%
unpow279.2%
times-frac88.2%
Applied egg-rr88.2%
*-commutative88.2%
associate-*l/88.3%
*-un-lft-identity88.3%
frac-times94.1%
*-un-lft-identity94.1%
associate-/l/94.2%
Applied egg-rr94.2%
Final simplification73.0%
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.0%
Taylor expanded in z around 0 53.6%
*-commutative53.6%
Simplified53.6%
Final simplification53.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z z))) (t_1 (* y t_0)) (t_2 (/ (/ 1.0 y) (* t_0 x))))
(if (< t_1 (- INFINITY))
t_2
(if (< t_1 8.680743250567252e+305) (/ (/ 1.0 x) (* t_0 y)) t_2))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * z) t_1 = y * t_0 t_2 = (1.0 / y) / (t_0 * x) tmp = 0 if t_1 < -math.inf: tmp = t_2 elif t_1 < 8.680743250567252e+305: tmp = (1.0 / x) / (t_0 * y) else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * z)) t_1 = Float64(y * t_0) t_2 = Float64(Float64(1.0 / y) / Float64(t_0 * x)) tmp = 0.0 if (t_1 < Float64(-Inf)) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = Float64(Float64(1.0 / x) / Float64(t_0 * y)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * z); t_1 = y * t_0; t_2 = (1.0 / y) / (t_0 * x); tmp = 0.0; if (t_1 < -Inf) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = (1.0 / x) / (t_0 * y); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / y), $MachinePrecision] / N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$1, (-Infinity)], t$95$2, If[Less[t$95$1, 8.680743250567252e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot z\\
t_1 := y \cdot t_0\\
t_2 := \frac{\frac{1}{y}}{t_0 \cdot x}\\
\mathbf{if}\;t_1 < -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 < 8.680743250567252 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0 \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
herbie shell --seed 2023311
(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)))))