
(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: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+167) (/ (/ 1.0 y) (* x (fma z z 1.0))) (/ (/ 1.0 (* x (* z y))) (hypot 1.0 z))))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+167) {
tmp = (1.0 / y) / (x * fma(z, z, 1.0));
} else {
tmp = (1.0 / (x * (z * y))) / hypot(1.0, z);
}
return tmp;
}
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+167) tmp = Float64(Float64(1.0 / y) / Float64(x * fma(z, z, 1.0))); else tmp = Float64(Float64(1.0 / Float64(x * Float64(z * y))) / hypot(1.0, z)); end return tmp end
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e+167], N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+167}:\\
\;\;\;\;\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot \left(z \cdot y\right)}}{\mathsf{hypot}\left(1, z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.0000000000000002e167Initial program 98.0%
associate-/r*97.7%
associate-/l/98.0%
associate-/r*98.0%
associate-/l/99.0%
sqr-neg99.0%
+-commutative99.0%
sqr-neg99.0%
fma-def99.0%
Simplified99.0%
if 4.0000000000000002e167 < (*.f64 z z) Initial program 70.1%
Taylor expanded in x around 0 70.1%
+-commutative70.1%
unpow270.1%
fma-udef70.1%
Simplified70.1%
associate-/r*70.1%
inv-pow70.1%
metadata-eval70.1%
pow-prod-up31.3%
frac-times32.4%
*-commutative32.4%
add-sqr-sqrt32.4%
associate-*l*32.4%
sqrt-div32.4%
sqrt-pow132.4%
metadata-eval32.4%
sqrt-div32.4%
sqrt-pow132.4%
metadata-eval32.4%
Applied egg-rr32.4%
associate-*l/32.4%
Simplified97.5%
Taylor expanded in z around inf 75.9%
Final simplification91.1%
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ (pow x -1.0) (* (hypot 1.0 z) y)) (hypot 1.0 z)))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
return (pow(x, -1.0) / (hypot(1.0, z) * y)) / hypot(1.0, z);
}
z = Math.abs(z);
assert x < y;
public static double code(double x, double y, double z) {
return (Math.pow(x, -1.0) / (Math.hypot(1.0, z) * y)) / Math.hypot(1.0, z);
}
z = abs(z) [x, y] = sort([x, y]) def code(x, y, z): return (math.pow(x, -1.0) / (math.hypot(1.0, z) * y)) / math.hypot(1.0, z)
z = abs(z) x, y = sort([x, y]) function code(x, y, z) return Float64(Float64((x ^ -1.0) / Float64(hypot(1.0, z) * y)) / hypot(1.0, z)) end
z = abs(z)
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = ((x ^ -1.0) / (hypot(1.0, z) * y)) / hypot(1.0, z);
end
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[Power[x, -1.0], $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{{x}^{-1}}{\mathsf{hypot}\left(1, z\right) \cdot y}}{\mathsf{hypot}\left(1, z\right)}
\end{array}
Initial program 88.4%
Taylor expanded in x around 0 88.2%
+-commutative88.2%
unpow288.2%
fma-udef88.2%
Simplified88.2%
associate-/r*88.4%
inv-pow88.4%
metadata-eval88.4%
pow-prod-up42.6%
frac-times43.8%
*-commutative43.8%
add-sqr-sqrt43.7%
associate-*l*43.7%
sqrt-div43.7%
sqrt-pow143.7%
metadata-eval43.7%
sqrt-div43.6%
sqrt-pow143.7%
metadata-eval43.7%
Applied egg-rr43.7%
associate-*l/43.7%
Simplified97.8%
Final simplification97.8%
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+167) (/ (/ 1.0 y) (* x (fma z z 1.0))) (/ (/ -1.0 z) (* x (* y (- z))))))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+167) {
tmp = (1.0 / y) / (x * fma(z, z, 1.0));
} else {
tmp = (-1.0 / z) / (x * (y * -z));
}
return tmp;
}
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+167) tmp = Float64(Float64(1.0 / y) / Float64(x * fma(z, z, 1.0))); else tmp = Float64(Float64(-1.0 / z) / Float64(x * Float64(y * Float64(-z)))); end return tmp end
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e+167], N[(N[(1.0 / y), $MachinePrecision] / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / z), $MachinePrecision] / N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+167}:\\
\;\;\;\;\frac{\frac{1}{y}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{z}}{x \cdot \left(y \cdot \left(-z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.0000000000000002e167Initial program 98.0%
associate-/r*97.7%
associate-/l/98.0%
associate-/r*98.0%
associate-/l/99.0%
sqr-neg99.0%
+-commutative99.0%
sqr-neg99.0%
fma-def99.0%
Simplified99.0%
if 4.0000000000000002e167 < (*.f64 z z) Initial program 70.1%
Taylor expanded in z around inf 70.1%
*-commutative70.1%
*-commutative70.1%
associate-*l*72.9%
Simplified72.9%
clear-num72.9%
associate-/r/72.9%
associate-/r*72.9%
*-commutative72.9%
associate-/r*70.1%
pow-flip73.1%
metadata-eval73.1%
Applied egg-rr73.1%
associate-/l/74.9%
add-sqr-sqrt74.8%
times-frac73.2%
sqrt-pow166.0%
metadata-eval66.0%
unpow-166.0%
sqrt-pow195.6%
metadata-eval95.6%
unpow-195.6%
Applied egg-rr95.6%
associate-/l/95.7%
frac-2neg95.7%
frac-times97.6%
*-un-lft-identity97.6%
distribute-neg-frac97.6%
metadata-eval97.6%
Applied egg-rr97.6%
Final simplification98.6%
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+126) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (/ (/ 1.0 z) (* y (* x z)))))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+126) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / z) / (y * (x * z));
}
return tmp;
}
NOTE: z should be positive before calling this function
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+126) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = (1.0d0 / z) / (y * (x * z))
end if
code = tmp
end function
z = Math.abs(z);
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+126) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / z) / (y * (x * z));
}
return tmp;
}
z = abs(z) [x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e+126: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = (1.0 / z) / (y * (x * z)) return tmp
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+126) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(1.0 / z) / Float64(y * Float64(x * z))); end return tmp end
z = abs(z)
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e+126)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = (1.0 / z) / (y * (x * z));
end
tmp_2 = tmp;
end
NOTE: z should be positive before calling this function 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+126], 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[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+126}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{y \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.99999999999999985e126Initial program 99.1%
if 1.99999999999999985e126 < (*.f64 z z) Initial program 71.2%
Taylor expanded in z around inf 71.2%
*-commutative71.2%
*-commutative71.2%
associate-*l*73.7%
Simplified73.7%
clear-num73.7%
associate-/r/73.7%
associate-/r*73.6%
*-commutative73.6%
associate-/r*72.1%
pow-flip74.8%
metadata-eval74.8%
Applied egg-rr74.8%
associate-/l/75.5%
add-sqr-sqrt75.4%
times-frac74.0%
sqrt-pow163.5%
metadata-eval63.5%
unpow-163.5%
sqrt-pow194.1%
metadata-eval94.1%
unpow-194.1%
Applied egg-rr94.1%
associate-/l/94.0%
frac-times96.9%
*-rgt-identity96.9%
Applied egg-rr96.9%
Final simplification98.2%
NOTE: z should be positive before calling this function 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 y) (* x z)))))
z = abs(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 * y) * (x * z));
}
return tmp;
}
NOTE: z should be positive before calling this function
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 * y) * (x * z))
end if
code = tmp
end function
z = Math.abs(z);
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 * y) * (x * z));
}
return tmp;
}
z = abs(z) [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 * y) * (x * z)) return tmp
z = abs(z) 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(1.0 / Float64(Float64(z * y) * Float64(x * z))); end return tmp end
z = abs(z)
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 * y) * (x * z));
end
tmp_2 = tmp;
end
NOTE: z should be positive before calling this function 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[(1.0 / N[(N[(z * y), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(z \cdot y\right) \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if z < 1Initial program 92.5%
associate-/r*92.2%
associate-/l/92.5%
associate-/r*92.5%
associate-/l/92.0%
sqr-neg92.0%
+-commutative92.0%
sqr-neg92.0%
fma-def92.0%
Simplified92.0%
Taylor expanded in z around 0 73.5%
if 1 < z Initial program 77.9%
Taylor expanded in z around inf 75.9%
*-commutative75.9%
*-commutative75.9%
associate-*l*80.9%
Simplified80.9%
clear-num80.9%
associate-/r/80.9%
associate-/r*80.8%
*-commutative80.8%
associate-/r*79.6%
pow-flip81.4%
metadata-eval81.4%
Applied egg-rr81.4%
associate-/l/82.6%
add-sqr-sqrt82.5%
times-frac78.7%
sqrt-pow178.8%
metadata-eval78.8%
unpow-178.8%
sqrt-pow191.0%
metadata-eval91.0%
unpow-191.0%
Applied egg-rr91.0%
associate-/l/91.1%
associate-/l/91.1%
frac-times90.2%
metadata-eval90.2%
Applied egg-rr90.2%
Final simplification78.2%
NOTE: z should be positive before calling this function 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) (* y (* x z)))))
z = abs(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) / (y * (x * z));
}
return tmp;
}
NOTE: z should be positive before calling this function
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) / (y * (x * z))
end if
code = tmp
end function
z = Math.abs(z);
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) / (y * (x * z));
}
return tmp;
}
z = abs(z) [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) / (y * (x * z)) return tmp
z = abs(z) 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 / z) / Float64(y * Float64(x * z))); end return tmp end
z = abs(z)
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) / (y * (x * z));
end
tmp_2 = tmp;
end
NOTE: z should be positive before calling this function 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 / z), $MachinePrecision] / N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[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}}{y \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if z < 1Initial program 92.5%
associate-/r*92.2%
associate-/l/92.5%
associate-/r*92.5%
associate-/l/92.0%
sqr-neg92.0%
+-commutative92.0%
sqr-neg92.0%
fma-def92.0%
Simplified92.0%
Taylor expanded in z around 0 73.5%
if 1 < z Initial program 77.9%
Taylor expanded in z around inf 75.9%
*-commutative75.9%
*-commutative75.9%
associate-*l*80.9%
Simplified80.9%
clear-num80.9%
associate-/r/80.9%
associate-/r*80.8%
*-commutative80.8%
associate-/r*79.6%
pow-flip81.4%
metadata-eval81.4%
Applied egg-rr81.4%
associate-/l/82.6%
add-sqr-sqrt82.5%
times-frac78.7%
sqrt-pow178.8%
metadata-eval78.8%
unpow-178.8%
sqrt-pow191.0%
metadata-eval91.0%
unpow-191.0%
Applied egg-rr91.0%
associate-/l/91.0%
frac-times96.4%
*-rgt-identity96.4%
Applied egg-rr96.4%
Final simplification79.9%
NOTE: z should be positive before calling this function 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 (* x (* z y)))))
z = abs(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 / (x * (z * y));
}
return tmp;
}
NOTE: z should be positive before calling this function
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 / (x * (z * y))
end if
code = tmp
end function
z = Math.abs(z);
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 / (x * (z * y));
}
return tmp;
}
z = abs(z) [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 / (x * (z * y)) return tmp
z = abs(z) 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(1.0 / Float64(x * Float64(z * y))); end return tmp end
z = abs(z)
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 / (x * (z * y));
end
tmp_2 = tmp;
end
NOTE: z should be positive before calling this function 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[(1.0 / N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(z \cdot y\right)}\\
\end{array}
\end{array}
if z < 1Initial program 92.5%
associate-/r*92.2%
associate-/l/92.5%
associate-/r*92.5%
associate-/l/92.0%
sqr-neg92.0%
+-commutative92.0%
sqr-neg92.0%
fma-def92.0%
Simplified92.0%
Taylor expanded in z around 0 73.5%
if 1 < z Initial program 77.9%
Taylor expanded in x around 0 77.9%
+-commutative77.9%
unpow277.9%
fma-udef77.9%
Simplified77.9%
associate-/r*77.9%
inv-pow77.9%
metadata-eval77.9%
pow-prod-up34.0%
frac-times36.6%
*-commutative36.6%
add-sqr-sqrt36.7%
associate-*l*36.7%
sqrt-div36.7%
sqrt-pow136.7%
metadata-eval36.7%
sqrt-div36.7%
sqrt-pow136.7%
metadata-eval36.7%
Applied egg-rr36.7%
associate-*l/36.7%
Simplified94.4%
Taylor expanded in z around inf 92.6%
Taylor expanded in z around 0 37.8%
Final simplification63.4%
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ 1.0 (* x y)))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
return 1.0 / (x * y);
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
assert x < y;
public static double code(double x, double y, double z) {
return 1.0 / (x * y);
}
z = abs(z) [x, y] = sort([x, y]) def code(x, y, z): return 1.0 / (x * y)
z = abs(z) x, y = sort([x, y]) function code(x, y, z) return Float64(1.0 / Float64(x * y)) end
z = abs(z)
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = 1.0 / (x * y);
end
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{x \cdot y}
\end{array}
Initial program 88.4%
Taylor expanded in z around 0 58.1%
*-commutative58.1%
Simplified58.1%
Final simplification58.1%
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 x) y))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / x) / y;
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / x) / y;
}
z = abs(z) [x, y] = sort([x, y]) def code(x, y, z): return (1.0 / x) / y
z = abs(z) x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / x) / y) end
z = abs(z)
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / x) / y;
end
NOTE: z should be positive before calling this function 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}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{x}}{y}
\end{array}
Initial program 88.4%
Taylor expanded in z around 0 58.2%
Final simplification58.2%
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 y) x))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / y) / x;
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / y) / x;
}
z = abs(z) [x, y] = sort([x, y]) def code(x, y, z): return (1.0 / y) / x
z = abs(z) x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / y) / x) end
z = abs(z)
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / y) / x;
end
NOTE: z should be positive before calling this function NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{y}}{x}
\end{array}
Initial program 88.4%
associate-/r*88.2%
associate-/l/88.4%
associate-/r*88.4%
associate-/l/89.1%
sqr-neg89.1%
+-commutative89.1%
sqr-neg89.1%
fma-def89.1%
Simplified89.1%
Taylor expanded in z around 0 58.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 2023310
(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)))))