
(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 (if (<= (* z z) 5e+69) (/ (/ (/ 1.0 x) y) (+ 1.0 (* z z))) (* (/ 1.0 z) (/ 1.0 (* y (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+69) {
tmp = ((1.0 / x) / y) / (1.0 + (z * z));
} else {
tmp = (1.0 / z) * (1.0 / (y * (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+69) then
tmp = ((1.0d0 / x) / y) / (1.0d0 + (z * z))
else
tmp = (1.0d0 / z) * (1.0d0 / (y * (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+69) {
tmp = ((1.0 / x) / y) / (1.0 + (z * z));
} else {
tmp = (1.0 / z) * (1.0 / (y * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e+69: tmp = ((1.0 / x) / y) / (1.0 + (z * z)) else: tmp = (1.0 / z) * (1.0 / (y * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+69) tmp = Float64(Float64(Float64(1.0 / x) / y) / Float64(1.0 + Float64(z * z))); else tmp = Float64(Float64(1.0 / z) * Float64(1.0 / Float64(y * Float64(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+69)
tmp = ((1.0 / x) / y) / (1.0 + (z * z));
else
tmp = (1.0 / z) * (1.0 / (y * (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+69], N[(N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision] / N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] * N[(1.0 / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+69}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z} \cdot \frac{1}{y \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000036e69Initial program 99.0%
associate-/r*99.7%
Simplified99.7%
if 5.00000000000000036e69 < (*.f64 z z) Initial program 82.7%
associate-/r*82.5%
+-commutative82.5%
fma-def82.5%
Simplified82.5%
Taylor expanded in z around inf 83.4%
unpow283.4%
*-commutative83.4%
associate-*l*79.4%
*-commutative79.4%
associate-*l*85.2%
Simplified85.2%
associate-/r*86.0%
div-inv86.0%
*-commutative86.0%
associate-*l*94.9%
Applied egg-rr94.9%
Final simplification97.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ (/ 1.0 y) (* x (hypot 1.0 z))) (hypot 1.0 z)))
assert(x < y);
double code(double x, double y, double z) {
return ((1.0 / y) / (x * hypot(1.0, z))) / hypot(1.0, z);
}
assert x < y;
public static double code(double x, double y, double z) {
return ((1.0 / y) / (x * Math.hypot(1.0, z))) / Math.hypot(1.0, z);
}
[x, y] = sort([x, y]) def code(x, y, z): return ((1.0 / y) / (x * math.hypot(1.0, z))) / math.hypot(1.0, z)
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(Float64(1.0 / y) / Float64(x * hypot(1.0, z))) / hypot(1.0, z)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = ((1.0 / y) / (x * hypot(1.0, z))) / hypot(1.0, z);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{\frac{1}{y}}{x \cdot \mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right)}
\end{array}
Initial program 91.7%
associate-/r*91.7%
+-commutative91.7%
fma-def91.7%
Simplified91.7%
fma-udef91.7%
+-commutative91.7%
associate-/r*91.7%
associate-/r*90.5%
add-sqr-sqrt90.5%
*-un-lft-identity90.5%
times-frac90.4%
hypot-1-def90.4%
associate-/l/90.4%
hypot-1-def93.3%
Applied egg-rr93.3%
associate-*l/93.3%
*-lft-identity93.3%
associate-/r*93.4%
associate-/l/97.6%
*-commutative97.6%
Simplified97.6%
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-5) (/ (/ 1.0 x) y) (* (/ 1.0 z) (/ 1.0 (* y (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = (1.0 / z) * (1.0 / (y * (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-5) then
tmp = (1.0d0 / x) / y
else
tmp = (1.0d0 / z) * (1.0d0 / (y * (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-5) {
tmp = (1.0 / x) / y;
} else {
tmp = (1.0 / z) * (1.0 / (y * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-5: tmp = (1.0 / x) / y else: tmp = (1.0 / z) * (1.0 / (y * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(1.0 / z) * Float64(1.0 / Float64(y * Float64(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-5)
tmp = (1.0 / x) / y;
else
tmp = (1.0 / z) * (1.0 / (y * (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-5], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] * N[(1.0 / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z} \cdot \frac{1}{y \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.7%
associate-/r*99.7%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt44.3%
times-frac44.3%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
associate-/r*44.3%
Simplified44.3%
div-inv44.2%
pow1/244.2%
pow-flip44.3%
metadata-eval44.3%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
Simplified44.3%
Taylor expanded in z around 0 99.0%
associate-/l/99.0%
Simplified99.0%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 83.5%
associate-/r*83.4%
+-commutative83.4%
fma-def83.4%
Simplified83.4%
Taylor expanded in z around inf 83.8%
unpow283.8%
*-commutative83.8%
associate-*l*80.9%
*-commutative80.9%
associate-*l*86.2%
Simplified86.2%
associate-/r*86.9%
div-inv86.9%
*-commutative86.9%
associate-*l*95.0%
Applied egg-rr95.0%
Final simplification97.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e+69) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (* (/ 1.0 z) (/ 1.0 (* y (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+69) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / z) * (1.0 / (y * (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+69) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = (1.0d0 / z) * (1.0d0 / (y * (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+69) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / z) * (1.0 / (y * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e+69: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = (1.0 / z) * (1.0 / (y * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+69) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(1.0 / z) * Float64(1.0 / Float64(y * Float64(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+69)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = (1.0 / z) * (1.0 / (y * (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+69], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] * N[(1.0 / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+69}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z} \cdot \frac{1}{y \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000036e69Initial program 99.0%
if 5.00000000000000036e69 < (*.f64 z z) Initial program 82.7%
associate-/r*82.5%
+-commutative82.5%
fma-def82.5%
Simplified82.5%
Taylor expanded in z around inf 83.4%
unpow283.4%
*-commutative83.4%
associate-*l*79.4%
*-commutative79.4%
associate-*l*85.2%
Simplified85.2%
associate-/r*86.0%
div-inv86.0%
*-commutative86.0%
associate-*l*94.9%
Applied egg-rr94.9%
Final simplification97.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-5) (/ (/ 1.0 x) y) (/ (/ (/ (- -1.0) y) (* x z)) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = ((-(-1.0) / y) / (x * z)) / z;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d-5) then
tmp = (1.0d0 / x) / y
else
tmp = ((-(-1.0d0) / y) / (x * z)) / z
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = ((-(-1.0) / y) / (x * z)) / z;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-5: tmp = (1.0 / x) / y else: tmp = ((-(-1.0) / y) / (x * z)) / z return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(Float64(Float64(-(-1.0)) / y) / Float64(x * 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) <= 5e-5)
tmp = (1.0 / x) / y;
else
tmp = ((-(-1.0) / y) / (x * z)) / z;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-5], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[((--1.0) / y), $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{--1}{y}}{x \cdot z}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.7%
associate-/r*99.7%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt44.3%
times-frac44.3%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
associate-/r*44.3%
Simplified44.3%
div-inv44.2%
pow1/244.2%
pow-flip44.3%
metadata-eval44.3%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
Simplified44.3%
Taylor expanded in z around 0 99.0%
associate-/l/99.0%
Simplified99.0%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 83.5%
associate-/r*83.4%
+-commutative83.4%
fma-def83.4%
Simplified83.4%
Taylor expanded in z around inf 83.8%
unpow283.8%
*-commutative83.8%
associate-*l*80.9%
*-commutative80.9%
associate-*l*86.2%
Simplified86.2%
Taylor expanded in z around 0 94.3%
metadata-eval94.3%
*-commutative94.3%
frac-times95.0%
associate-/r/94.2%
frac-2neg94.2%
metadata-eval94.2%
div-inv94.2%
distribute-neg-frac94.2%
frac-2neg94.2%
*-commutative94.2%
associate-*r*94.9%
*-commutative94.9%
distribute-rgt-neg-in94.9%
*-commutative94.9%
add-sqr-sqrt45.7%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod27.1%
add-sqr-sqrt52.4%
associate-*r*52.4%
*-commutative52.4%
Applied egg-rr95.1%
Final simplification97.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-5) (/ (/ 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) <= 5e-5) {
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) <= 5d-5) 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) <= 5e-5) {
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) <= 5e-5: 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) <= 5e-5) 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) <= 5e-5)
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], 5e-5], 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 5 \cdot 10^{-5}:\\
\;\;\;\;\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) < 5.00000000000000024e-5Initial program 99.7%
associate-/r*99.7%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt44.3%
times-frac44.3%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
associate-/r*44.3%
Simplified44.3%
div-inv44.2%
pow1/244.2%
pow-flip44.3%
metadata-eval44.3%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
Simplified44.3%
Taylor expanded in z around 0 99.0%
associate-/l/99.0%
Simplified99.0%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 83.5%
associate-/r*83.4%
+-commutative83.4%
fma-def83.4%
Simplified83.4%
Taylor expanded in z around inf 83.0%
unpow283.0%
associate-*r*89.7%
*-commutative89.7%
Simplified89.7%
Final simplification94.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-5) (/ (/ 1.0 x) y) (/ 1.0 (* z (* y (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-5) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (z * (y * (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-5) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (z * (y * (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-5) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (z * (y * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e-5: tmp = (1.0 / x) / y else: tmp = 1.0 / (z * (y * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(z * Float64(y * Float64(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-5)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (z * (y * (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-5], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(z * N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(x \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.7%
associate-/r*99.7%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt44.3%
times-frac44.3%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
associate-/r*44.3%
Simplified44.3%
div-inv44.2%
pow1/244.2%
pow-flip44.3%
metadata-eval44.3%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
Simplified44.3%
Taylor expanded in z around 0 99.0%
associate-/l/99.0%
Simplified99.0%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 83.5%
associate-/r*83.4%
+-commutative83.4%
fma-def83.4%
Simplified83.4%
Taylor expanded in z around inf 83.8%
unpow283.8%
*-commutative83.8%
associate-*l*80.9%
*-commutative80.9%
associate-*l*86.2%
Simplified86.2%
Taylor expanded in z around 0 94.3%
Final simplification96.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 91.7%
associate-/r*91.7%
+-commutative91.7%
fma-def91.7%
Simplified91.7%
Taylor expanded in z around 0 58.2%
Final simplification58.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 91.7%
associate-/r*90.5%
Simplified90.5%
*-un-lft-identity90.5%
add-sqr-sqrt46.9%
times-frac46.9%
Applied egg-rr46.9%
associate-*l/46.9%
*-lft-identity46.9%
associate-/r*46.9%
Simplified46.9%
div-inv46.8%
pow1/246.8%
pow-flip46.9%
metadata-eval46.9%
Applied egg-rr46.9%
associate-*l/47.0%
*-lft-identity47.0%
Simplified47.0%
Taylor expanded in z around 0 58.2%
associate-/l/58.2%
Simplified58.2%
Final simplification58.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z z))) (t_1 (* y t_0)) (t_2 (/ (/ 1.0 y) (* t_0 x))))
(if (< t_1 (- INFINITY))
t_2
(if (< t_1 8.680743250567252e+305) (/ (/ 1.0 x) (* t_0 y)) t_2))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * z) t_1 = y * t_0 t_2 = (1.0 / y) / (t_0 * x) tmp = 0 if t_1 < -math.inf: tmp = t_2 elif t_1 < 8.680743250567252e+305: tmp = (1.0 / x) / (t_0 * y) else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * z)) t_1 = Float64(y * t_0) t_2 = Float64(Float64(1.0 / y) / Float64(t_0 * x)) tmp = 0.0 if (t_1 < Float64(-Inf)) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = Float64(Float64(1.0 / x) / Float64(t_0 * y)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * z); t_1 = y * t_0; t_2 = (1.0 / y) / (t_0 * x); tmp = 0.0; if (t_1 < -Inf) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = (1.0 / x) / (t_0 * y); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / y), $MachinePrecision] / N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$1, (-Infinity)], t$95$2, If[Less[t$95$1, 8.680743250567252e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot z\\
t_1 := y \cdot t_0\\
t_2 := \frac{\frac{1}{y}}{t_0 \cdot x}\\
\mathbf{if}\;t_1 < -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 < 8.680743250567252 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0 \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
herbie shell --seed 2023224
(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)))))