
(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 (* (hypot 1.0 z) (sqrt y))))
(if (<= (* y (+ 1.0 (* z z))) 5e+303)
(/ (/ 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))) <= 5e+303) {
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))) <= 5e+303) 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], 5e+303], 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 5 \cdot 10^{+303}:\\
\;\;\;\;\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.9999999999999997e303Initial program 96.1%
distribute-lft-in96.1%
*-rgt-identity96.1%
+-commutative96.1%
associate-*r*97.9%
fma-def97.9%
Applied egg-rr97.9%
if 4.9999999999999997e303 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 79.3%
associate-/r*79.3%
*-commutative79.3%
sqr-neg79.3%
+-commutative79.3%
distribute-lft1-in79.3%
*-commutative79.3%
fma-def79.3%
sqr-neg79.3%
Simplified79.3%
*-commutative79.3%
fma-udef79.3%
*-rgt-identity79.3%
distribute-lft-in79.3%
+-commutative79.3%
/-rgt-identity79.3%
clear-num79.3%
div-inv79.3%
add-sqr-sqrt79.3%
associate-/l*79.3%
+-commutative79.3%
fma-udef79.3%
*-commutative79.3%
sqrt-prod79.3%
fma-udef79.3%
+-commutative79.3%
hypot-1-def79.3%
+-commutative79.3%
fma-udef79.3%
*-commutative79.3%
sqrt-prod79.3%
Applied egg-rr99.8%
Final simplification98.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e-5) (/ (- 1.0 (* z z)) (* y x)) (* (/ 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-5) {
tmp = (1.0 - (z * z)) / (y * x);
} 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) <= 2d-5) then
tmp = (1.0d0 - (z * z)) / (y * x)
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) <= 2e-5) {
tmp = (1.0 - (z * z)) / (y * x);
} 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) <= 2e-5: tmp = (1.0 - (z * z)) / (y * x) 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-5) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y * x)); else tmp = Float64(Float64(1.0 / Float64(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) <= 2e-5)
tmp = (1.0 - (z * z)) / (y * x);
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], 2e-5], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y * z), $MachinePrecision]), $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^{-5}:\\
\;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot z} \cdot \frac{\frac{1}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000016e-5Initial program 99.7%
associate-/r*99.6%
*-commutative99.6%
sqr-neg99.6%
+-commutative99.6%
distribute-lft1-in99.6%
*-commutative99.6%
fma-def99.6%
sqr-neg99.6%
Simplified99.6%
Taylor expanded in z around 0 90.2%
associate-/l/90.3%
+-commutative90.3%
mul-1-neg90.3%
unsub-neg90.3%
associate-/r*90.2%
unpow290.2%
*-commutative90.2%
div-sub99.3%
Simplified99.3%
if 2.00000000000000016e-5 < (*.f64 z z) Initial program 86.1%
Taylor expanded in z around inf 85.3%
unpow285.3%
Simplified85.3%
*-un-lft-identity85.3%
associate-*r*93.8%
times-frac97.7%
Applied egg-rr97.7%
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) 4000000000000.0) (/ 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) <= 4000000000000.0) {
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) <= 4000000000000.0d0) 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) <= 4000000000000.0) {
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) <= 4000000000000.0: 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) <= 4000000000000.0) tmp = Float64(1.0 / Float64(x * Float64(y + Float64(y * Float64(z * z))))); else tmp = Float64(Float64(1.0 / Float64(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) <= 4000000000000.0)
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], 4000000000000.0], N[(1.0 / N[(x * N[(y + N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y * z), $MachinePrecision]), $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 4000000000000:\\
\;\;\;\;\frac{1}{x \cdot \left(y + y \cdot \left(z \cdot z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot z} \cdot \frac{\frac{1}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 4e12Initial program 99.7%
associate-/r*99.6%
*-commutative99.6%
sqr-neg99.6%
+-commutative99.6%
distribute-lft1-in99.6%
*-commutative99.6%
fma-def99.6%
sqr-neg99.6%
Simplified99.6%
fma-udef99.6%
Applied egg-rr99.6%
if 4e12 < (*.f64 z z) Initial program 85.8%
Taylor expanded in z around inf 85.8%
unpow285.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-*r*94.4%
times-frac98.4%
Applied egg-rr98.4%
Final simplification99.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e+70) (/ (/ 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) <= 1e+70) {
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) <= 1d+70) 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) <= 1e+70) {
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) <= 1e+70: 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) <= 1e+70) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(1.0 / Float64(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) <= 1e+70)
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], 1e+70], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y * z), $MachinePrecision]), $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 10^{+70}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot z} \cdot \frac{\frac{1}{x}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.00000000000000007e70Initial program 99.6%
if 1.00000000000000007e70 < (*.f64 z z) Initial program 84.3%
Taylor expanded in z around inf 84.3%
unpow284.3%
Simplified84.3%
*-un-lft-identity84.3%
associate-*r*93.9%
times-frac98.3%
Applied egg-rr98.3%
Final simplification99.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e-5) (/ (/ 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) <= 2e-5) {
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) <= 2d-5) 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) <= 2e-5) {
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) <= 2e-5: 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) <= 2e-5) 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) <= 2e-5)
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], 2e-5], 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 2 \cdot 10^{-5}:\\
\;\;\;\;\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) < 2.00000000000000016e-5Initial program 99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
+-commutative99.7%
associate-*r*99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 98.5%
if 2.00000000000000016e-5 < (*.f64 z z) Initial program 86.1%
associate-/r*85.5%
*-commutative85.5%
sqr-neg85.5%
+-commutative85.5%
distribute-lft1-in85.5%
*-commutative85.5%
fma-def85.5%
sqr-neg85.5%
Simplified85.5%
Taylor expanded in z around inf 84.8%
unpow284.8%
Simplified84.8%
Final simplification91.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e-5) (/ (/ 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) <= 2e-5) {
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) <= 2d-5) 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) <= 2e-5) {
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) <= 2e-5: 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) <= 2e-5) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(y * Float64(z * Float64(z * x)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e-5)
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], 2e-5], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(y * N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000016e-5Initial program 99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
+-commutative99.7%
associate-*r*99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 98.5%
if 2.00000000000000016e-5 < (*.f64 z z) Initial program 86.1%
distribute-lft-in86.1%
*-rgt-identity86.1%
+-commutative86.1%
associate-*r*94.5%
fma-def94.5%
Applied egg-rr94.5%
Taylor expanded in z around inf 84.8%
*-commutative84.8%
unpow284.8%
associate-*r*93.2%
associate-*r*96.4%
associate-*l*88.1%
*-commutative88.1%
Simplified88.1%
Final simplification93.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-5) (/ (/ 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) <= 2e-5) {
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) <= 2d-5) 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) <= 2e-5) {
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) <= 2e-5: 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) <= 2e-5) 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) <= 2e-5)
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], 2e-5], 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 2 \cdot 10^{-5}:\\
\;\;\;\;\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) < 2.00000000000000016e-5Initial program 99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
+-commutative99.7%
associate-*r*99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 98.5%
if 2.00000000000000016e-5 < (*.f64 z z) Initial program 86.1%
associate-/r*85.5%
*-commutative85.5%
sqr-neg85.5%
+-commutative85.5%
distribute-lft1-in85.5%
*-commutative85.5%
fma-def85.5%
sqr-neg85.5%
Simplified85.5%
fma-udef85.5%
Applied egg-rr85.5%
Taylor expanded in z around inf 84.8%
*-commutative84.8%
unpow284.8%
associate-*r*93.2%
associate-*r*96.4%
*-commutative96.4%
Simplified96.4%
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-5) (/ (- 1.0 (* z z)) (* y x)) (/ 1.0 (* (* y z) (* z x)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-5) {
tmp = (1.0 - (z * z)) / (y * x);
} else {
tmp = 1.0 / ((y * z) * (z * x));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 2d-5) then
tmp = (1.0d0 - (z * z)) / (y * x)
else
tmp = 1.0d0 / ((y * z) * (z * x))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-5) {
tmp = (1.0 - (z * z)) / (y * x);
} else {
tmp = 1.0 / ((y * z) * (z * x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e-5: tmp = (1.0 - (z * z)) / (y * x) else: tmp = 1.0 / ((y * z) * (z * x)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e-5) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y * x)); 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) <= 2e-5)
tmp = (1.0 - (z * z)) / (y * x);
else
tmp = 1.0 / ((y * z) * (z * x));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e-5], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $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 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(y \cdot z\right) \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000016e-5Initial program 99.7%
associate-/r*99.6%
*-commutative99.6%
sqr-neg99.6%
+-commutative99.6%
distribute-lft1-in99.6%
*-commutative99.6%
fma-def99.6%
sqr-neg99.6%
Simplified99.6%
Taylor expanded in z around 0 90.2%
associate-/l/90.3%
+-commutative90.3%
mul-1-neg90.3%
unsub-neg90.3%
associate-/r*90.2%
unpow290.2%
*-commutative90.2%
div-sub99.3%
Simplified99.3%
if 2.00000000000000016e-5 < (*.f64 z z) Initial program 86.1%
associate-/r*85.5%
*-commutative85.5%
sqr-neg85.5%
+-commutative85.5%
distribute-lft1-in85.5%
*-commutative85.5%
fma-def85.5%
sqr-neg85.5%
Simplified85.5%
fma-udef85.5%
Applied egg-rr85.5%
Taylor expanded in z around inf 84.8%
*-commutative84.8%
unpow284.8%
associate-*r*93.2%
associate-*r*96.4%
*-commutative96.4%
Simplified96.4%
Final simplification97.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 1.0) (/ (/ 1.0 x) y) (/ 1.0 (* x (* y z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (y * z));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 1.0d0) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (x * (y * z))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (y * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 1.0: tmp = (1.0 / x) / y else: tmp = 1.0 / (x * (y * z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 1.0) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(x * Float64(y * z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (z <= 1.0)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (x * (y * z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[z, 1.0], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(y \cdot z\right)}\\
\end{array}
\end{array}
if z < 1Initial program 97.8%
distribute-lft-in97.8%
*-rgt-identity97.8%
+-commutative97.8%
associate-*r*99.2%
fma-def99.2%
Applied egg-rr99.2%
Taylor expanded in z around 0 72.8%
if 1 < z Initial program 76.2%
associate-/r*76.2%
*-commutative76.2%
sqr-neg76.2%
+-commutative76.2%
distribute-lft1-in76.2%
*-commutative76.2%
fma-def76.2%
sqr-neg76.2%
Simplified76.2%
associate-/r*76.2%
fma-udef76.3%
*-rgt-identity76.3%
distribute-lft-in76.2%
+-commutative76.2%
associate-/r*72.3%
associate-/r*72.4%
*-un-lft-identity72.4%
+-commutative72.4%
fma-udef72.4%
add-sqr-sqrt72.4%
times-frac72.3%
fma-udef72.3%
+-commutative72.3%
hypot-1-def72.3%
*-commutative72.3%
associate-/r*72.3%
fma-udef72.3%
+-commutative72.3%
hypot-1-def82.5%
Applied egg-rr82.5%
Taylor expanded in z around inf 82.5%
Taylor expanded in z around 0 47.7%
Final simplification67.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ 1.0 (* y x)))
assert(x < y);
double code(double x, double y, double z) {
return 1.0 / (y * x);
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 / (y * x)
end function
assert x < y;
public static double code(double x, double y, double z) {
return 1.0 / (y * x);
}
[x, y] = sort([x, y]) def code(x, y, z): return 1.0 / (y * x)
x, y = sort([x, y]) function code(x, y, z) return Float64(1.0 / Float64(y * x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = 1.0 / (y * x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{y \cdot x}
\end{array}
Initial program 93.1%
associate-/r*92.8%
*-commutative92.8%
sqr-neg92.8%
+-commutative92.8%
distribute-lft1-in92.8%
*-commutative92.8%
fma-def92.8%
sqr-neg92.8%
Simplified92.8%
Taylor expanded in z around 0 62.0%
*-commutative62.0%
Simplified62.0%
Final simplification62.0%
(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 2023290
(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)))))