
(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 12 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))) 4e+287)
(/ (/ 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))) <= 4e+287) {
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))) <= 4e+287) tmp = Float64(Float64(1.0 / x) / fma(Float64(y * z), z, y)); else tmp = Float64(1.0 / Float64(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], 4e+287], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $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 4 \cdot 10^{+287}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y \cdot z, z, y\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))) < 4.0000000000000003e287Initial program 96.1%
distribute-lft-in96.1%
*-rgt-identity96.1%
+-commutative96.1%
associate-*r*97.4%
fma-def97.4%
Applied egg-rr97.4%
if 4.0000000000000003e287 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 76.8%
associate-/r*76.8%
*-commutative76.8%
sqr-neg76.8%
+-commutative76.8%
distribute-lft1-in76.8%
*-commutative76.8%
fma-def76.8%
sqr-neg76.8%
Simplified76.8%
*-commutative76.8%
fma-udef76.8%
*-rgt-identity76.8%
distribute-lft-in76.8%
+-commutative76.8%
/-rgt-identity76.8%
clear-num76.8%
div-inv76.8%
add-sqr-sqrt76.8%
associate-/l*76.8%
+-commutative76.8%
fma-udef76.8%
*-commutative76.8%
sqrt-prod76.8%
fma-udef76.8%
+-commutative76.8%
hypot-1-def76.8%
+-commutative76.8%
fma-udef76.8%
*-commutative76.8%
sqrt-prod83.6%
Applied egg-rr99.7%
Final simplification97.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 2.9e-286) (/ (/ 1.0 x) (fma (* y z) z y)) (/ (/ 1.0 (hypot 1.0 z)) (* y (* x (hypot 1.0 z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.9e-286) {
tmp = (1.0 / x) / fma((y * z), z, y);
} else {
tmp = (1.0 / hypot(1.0, z)) / (y * (x * hypot(1.0, z)));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (y <= 2.9e-286) tmp = Float64(Float64(1.0 / x) / fma(Float64(y * z), z, y)); else tmp = Float64(Float64(1.0 / hypot(1.0, z)) / Float64(y * Float64(x * hypot(1.0, z)))); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 2.9e-286], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[(y * N[(x * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{-286}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{y \cdot \left(x \cdot \mathsf{hypot}\left(1, z\right)\right)}\\
\end{array}
\end{array}
if y < 2.8999999999999998e-286Initial program 93.8%
distribute-lft-in93.8%
*-rgt-identity93.8%
+-commutative93.8%
associate-*r*96.4%
fma-def96.4%
Applied egg-rr96.4%
if 2.8999999999999998e-286 < y Initial program 92.0%
distribute-lft-in92.0%
*-rgt-identity92.0%
+-commutative92.0%
associate-*r*93.7%
fma-def93.7%
Applied egg-rr93.7%
fma-udef93.7%
associate-*l*92.0%
*-un-lft-identity92.0%
*-commutative92.0%
distribute-lft-in92.0%
fma-udef92.0%
associate-/r*92.8%
associate-/r*93.0%
associate-/l/92.9%
fma-udef92.9%
+-commutative92.9%
metadata-eval92.9%
add-sqr-sqrt92.9%
hypot-udef92.9%
hypot-udef92.9%
associate-/l/95.5%
div-inv95.5%
Applied egg-rr99.0%
associate-*l/99.0%
*-lft-identity99.0%
Simplified99.0%
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) 2e+242) (* (/ 1.0 y) (/ (/ 1.0 x) (fma z z 1.0))) (* (/ (/ 1.0 y) z) (/ (/ 1.0 x) z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+242) {
tmp = (1.0 / y) * ((1.0 / x) / fma(z, z, 1.0));
} else {
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+242) tmp = Float64(Float64(1.0 / y) * Float64(Float64(1.0 / x) / fma(z, z, 1.0))); else tmp = Float64(Float64(Float64(1.0 / y) / z) * Float64(Float64(1.0 / x) / z)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+242], N[(N[(1.0 / y), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+242}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{\frac{1}{x}}{\mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z} \cdot \frac{\frac{1}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.0000000000000001e242Initial program 98.0%
associate-/r*97.4%
*-commutative97.4%
sqr-neg97.4%
+-commutative97.4%
distribute-lft1-in97.4%
*-commutative97.4%
fma-def97.4%
sqr-neg97.4%
Simplified97.4%
associate-/r*98.1%
*-un-lft-identity98.1%
fma-udef98.0%
*-rgt-identity98.0%
distribute-lft-in98.0%
fma-udef98.0%
times-frac98.5%
Applied egg-rr98.5%
if 2.0000000000000001e242 < (*.f64 z z) Initial program 80.1%
associate-/r*80.1%
*-commutative80.1%
sqr-neg80.1%
+-commutative80.1%
distribute-lft1-in80.1%
*-commutative80.1%
fma-def80.1%
sqr-neg80.1%
Simplified80.1%
Taylor expanded in z around inf 80.1%
unpow280.1%
associate-*r*77.1%
*-commutative77.1%
Simplified77.1%
associate-/r*77.0%
associate-/r*77.0%
div-inv77.0%
times-frac98.5%
Applied egg-rr98.5%
Final simplification98.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.04) (/ (/ 1.0 x) y) (* (/ (/ 1.0 y) z) (/ (/ 1.0 x) z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.04) {
tmp = (1.0 / x) / y;
} else {
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 0.04d0) then
tmp = (1.0d0 / x) / y
else
tmp = ((1.0d0 / y) / z) * ((1.0d0 / x) / z)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.04) {
tmp = (1.0 / x) / y;
} else {
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 0.04: tmp = (1.0 / x) / y else: tmp = ((1.0 / y) / z) * ((1.0 / x) / z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 0.04) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(Float64(1.0 / y) / z) * Float64(Float64(1.0 / x) / z)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 0.04)
tmp = (1.0 / x) / y;
else
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 0.04], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.04:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z} \cdot \frac{\frac{1}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.0400000000000000008Initial program 99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
+-commutative99.6%
associate-*r*99.6%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 97.8%
associate-/r*98.7%
Simplified98.7%
if 0.0400000000000000008 < (*.f64 z z) Initial program 86.3%
associate-/r*86.4%
*-commutative86.4%
sqr-neg86.4%
+-commutative86.4%
distribute-lft1-in86.4%
*-commutative86.4%
fma-def86.4%
sqr-neg86.4%
Simplified86.4%
Taylor expanded in z around inf 85.8%
unpow285.8%
associate-*r*82.7%
*-commutative82.7%
Simplified82.7%
associate-/r*82.7%
associate-/r*82.6%
div-inv82.6%
times-frac96.4%
Applied egg-rr96.4%
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 z) 5e+53) (/ 1.0 (* x (+ y (* y (* z z))))) (* (/ (/ 1.0 y) z) (/ (/ 1.0 x) z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+53) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d+53) then
tmp = 1.0d0 / (x * (y + (y * (z * z))))
else
tmp = ((1.0d0 / y) / z) * ((1.0d0 / x) / z)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+53) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e+53: tmp = 1.0 / (x * (y + (y * (z * z)))) else: tmp = ((1.0 / y) / z) * ((1.0 / x) / z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+53) tmp = Float64(1.0 / Float64(x * Float64(y + Float64(y * Float64(z * z))))); else tmp = Float64(Float64(Float64(1.0 / y) / z) * Float64(Float64(1.0 / x) / z)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e+53)
tmp = 1.0 / (x * (y + (y * (z * z))));
else
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+53], N[(1.0 / N[(x * N[(y + N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+53}:\\
\;\;\;\;\frac{1}{x \cdot \left(y + y \cdot \left(z \cdot z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z} \cdot \frac{\frac{1}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000004e53Initial program 99.6%
associate-/r*98.7%
*-commutative98.7%
sqr-neg98.7%
+-commutative98.7%
distribute-lft1-in98.7%
*-commutative98.7%
fma-def98.7%
sqr-neg98.7%
Simplified98.7%
fma-udef98.7%
Applied egg-rr98.7%
if 5.0000000000000004e53 < (*.f64 z z) Initial program 85.2%
associate-/r*85.2%
*-commutative85.2%
sqr-neg85.2%
+-commutative85.2%
distribute-lft1-in85.2%
*-commutative85.2%
fma-def85.2%
sqr-neg85.2%
Simplified85.2%
Taylor expanded in z around inf 85.2%
unpow285.2%
associate-*r*81.9%
*-commutative81.9%
Simplified81.9%
associate-/r*81.9%
associate-/r*81.8%
div-inv81.8%
times-frac96.8%
Applied egg-rr96.8%
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) 5e+53) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (* (/ (/ 1.0 y) z) (/ (/ 1.0 x) z))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+53) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d+53) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = ((1.0d0 / y) / z) * ((1.0d0 / x) / z)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+53) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e+53: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = ((1.0 / y) / z) * ((1.0 / x) / z) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+53) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(Float64(1.0 / y) / z) * Float64(Float64(1.0 / x) / z)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e+53)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = ((1.0 / y) / z) * ((1.0 / x) / z);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+53], 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[(N[(1.0 / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+53}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z} \cdot \frac{\frac{1}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000004e53Initial program 99.6%
if 5.0000000000000004e53 < (*.f64 z z) Initial program 85.2%
associate-/r*85.2%
*-commutative85.2%
sqr-neg85.2%
+-commutative85.2%
distribute-lft1-in85.2%
*-commutative85.2%
fma-def85.2%
sqr-neg85.2%
Simplified85.2%
Taylor expanded in z around inf 85.2%
unpow285.2%
associate-*r*81.9%
*-commutative81.9%
Simplified81.9%
associate-/r*81.9%
associate-/r*81.8%
div-inv81.8%
times-frac96.8%
Applied egg-rr96.8%
Final simplification98.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z 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 * 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 * 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 * 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 * 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 (Float64(z * 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 * 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[N[(z * z), $MachinePrecision], 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 \cdot 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 (*.f64 z z) < 1Initial program 99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
+-commutative99.6%
associate-*r*99.6%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 97.8%
associate-/r*98.7%
Simplified98.7%
if 1 < (*.f64 z z) Initial program 86.3%
associate-/r*86.4%
*-commutative86.4%
sqr-neg86.4%
+-commutative86.4%
distribute-lft1-in86.4%
*-commutative86.4%
fma-def86.4%
sqr-neg86.4%
Simplified86.4%
Taylor expanded in z around inf 85.8%
unpow285.8%
Simplified85.8%
Final simplification92.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.04) (/ (/ 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.04) {
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.04d0) 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.04) {
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.04: 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.04) 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.04)
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.04], 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.04:\\
\;\;\;\;\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.0400000000000000008Initial program 99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
+-commutative99.6%
associate-*r*99.6%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 97.8%
associate-/r*98.7%
Simplified98.7%
if 0.0400000000000000008 < (*.f64 z z) Initial program 86.3%
associate-/r*86.4%
*-commutative86.4%
sqr-neg86.4%
+-commutative86.4%
distribute-lft1-in86.4%
*-commutative86.4%
fma-def86.4%
sqr-neg86.4%
Simplified86.4%
Taylor expanded in z around inf 85.8%
unpow285.8%
associate-*r*82.7%
*-commutative82.7%
Simplified82.7%
Taylor expanded in y around 0 85.8%
unpow285.8%
*-commutative85.8%
associate-*l*90.3%
*-commutative90.3%
Simplified90.3%
Final simplification94.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 0.04) (/ (/ 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.04) {
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.04d0) 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.04) {
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.04: 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.04) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(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.04)
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.04], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(N[(y * z), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.04:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(y \cdot z\right) \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.0400000000000000008Initial program 99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
+-commutative99.6%
associate-*r*99.6%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 97.8%
associate-/r*98.7%
Simplified98.7%
if 0.0400000000000000008 < (*.f64 z z) Initial program 86.3%
associate-/r*86.4%
*-commutative86.4%
sqr-neg86.4%
+-commutative86.4%
distribute-lft1-in86.4%
*-commutative86.4%
fma-def86.4%
sqr-neg86.4%
Simplified86.4%
Taylor expanded in z around inf 85.8%
unpow285.8%
associate-*r*82.7%
*-commutative82.7%
Simplified82.7%
associate-/r*82.7%
associate-/r*82.6%
div-inv82.6%
times-frac96.4%
Applied egg-rr96.4%
clear-num95.4%
clear-num95.4%
frac-times95.4%
metadata-eval95.4%
div-inv95.4%
remove-double-div95.4%
*-commutative95.4%
div-inv95.5%
clear-num95.5%
/-rgt-identity95.5%
*-commutative95.5%
Applied egg-rr95.5%
Final simplification97.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.04) (/ (/ 1.0 x) y) (/ (/ (/ 1.0 z) y) (* z x))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.04) {
tmp = (1.0 / x) / y;
} else {
tmp = ((1.0 / z) / y) / (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.04d0) then
tmp = (1.0d0 / x) / y
else
tmp = ((1.0d0 / z) / y) / (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.04) {
tmp = (1.0 / x) / y;
} else {
tmp = ((1.0 / z) / y) / (z * x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 0.04: tmp = (1.0 / x) / y else: tmp = ((1.0 / z) / y) / (z * x) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 0.04) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(Float64(1.0 / z) / y) / 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.04)
tmp = (1.0 / x) / y;
else
tmp = ((1.0 / z) / y) / (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.04], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(1.0 / z), $MachinePrecision] / y), $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.04:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{z}}{y}}{z \cdot x}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.0400000000000000008Initial program 99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
+-commutative99.6%
associate-*r*99.6%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 97.8%
associate-/r*98.7%
Simplified98.7%
if 0.0400000000000000008 < (*.f64 z z) Initial program 86.3%
associate-/r*86.4%
*-commutative86.4%
sqr-neg86.4%
+-commutative86.4%
distribute-lft1-in86.4%
*-commutative86.4%
fma-def86.4%
sqr-neg86.4%
Simplified86.4%
Taylor expanded in z around inf 85.8%
unpow285.8%
associate-*r*82.7%
*-commutative82.7%
Simplified82.7%
associate-/r*82.7%
associate-/r*82.6%
div-inv82.6%
times-frac96.4%
Applied egg-rr96.4%
associate-/l/96.5%
un-div-inv96.5%
associate-/l/95.5%
associate-/r*96.6%
*-commutative96.6%
Applied egg-rr96.6%
Final simplification97.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ 1.0 (* y x)))
assert(x < y);
double code(double x, double y, double z) {
return 1.0 / (y * x);
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 / (y * x)
end function
assert x < y;
public static double code(double x, double y, double z) {
return 1.0 / (y * x);
}
[x, y] = sort([x, y]) def code(x, y, z): return 1.0 / (y * x)
x, y = sort([x, y]) function code(x, y, z) return Float64(1.0 / Float64(y * x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = 1.0 / (y * x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{y \cdot x}
\end{array}
Initial program 93.0%
associate-/r*92.5%
*-commutative92.5%
sqr-neg92.5%
+-commutative92.5%
distribute-lft1-in92.5%
*-commutative92.5%
fma-def92.5%
sqr-neg92.5%
Simplified92.5%
Taylor expanded in z around 0 59.2%
*-commutative59.2%
Simplified59.2%
Final simplification59.2%
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 93.0%
distribute-lft-in93.0%
*-rgt-identity93.0%
+-commutative93.0%
associate-*r*95.3%
fma-def95.2%
Applied egg-rr95.2%
Taylor expanded in z around 0 59.2%
associate-/r*59.6%
Simplified59.6%
Final simplification59.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 2023293
(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)))))