
(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 2e+91) (/ (/ (- -1.0) (* x y)) (fma z z 1.0)) (/ (/ 1.0 z) (* x (* z y)))))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 2e+91) {
tmp = (-(-1.0) / (x * y)) / fma(z, z, 1.0);
} else {
tmp = (1.0 / z) / (x * (z * y));
}
return tmp;
}
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 2e+91) tmp = Float64(Float64(Float64(-(-1.0)) / Float64(x * y)) / fma(z, z, 1.0)); else tmp = Float64(Float64(1.0 / z) / Float64(x * Float64(z * y))); 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[z, 2e+91], N[(N[((--1.0) / N[(x * y), $MachinePrecision]), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / 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 2 \cdot 10^{+91}:\\
\;\;\;\;\frac{\frac{--1}{x \cdot y}}{\mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\
\end{array}
\end{array}
if z < 2.00000000000000016e91Initial program 95.3%
associate-/l/94.6%
associate-*l*92.9%
*-commutative92.9%
sqr-neg92.9%
+-commutative92.9%
sqr-neg92.9%
fma-def92.9%
Simplified92.9%
frac-2neg92.9%
div-inv92.9%
metadata-eval92.9%
mul-1-neg92.9%
neg-sub092.9%
*-commutative92.9%
distribute-rgt-neg-in92.9%
associate-/r*92.9%
associate-/r*93.4%
associate-/r*95.3%
div-inv95.3%
times-frac95.3%
remove-double-neg95.3%
distribute-neg-frac95.3%
frac-2neg95.3%
cancel-sign-sub-inv95.3%
Applied egg-rr95.3%
+-lft-identity95.3%
distribute-neg-frac95.3%
metadata-eval95.3%
associate-*l/95.3%
mul-1-neg95.3%
associate-/l/95.3%
*-commutative95.3%
Simplified95.3%
if 2.00000000000000016e91 < z Initial program 74.9%
associate-/l/75.0%
associate-*l*77.3%
*-commutative77.3%
sqr-neg77.3%
+-commutative77.3%
sqr-neg77.3%
fma-def77.3%
Simplified77.3%
Taylor expanded in z around inf 77.3%
unpow277.3%
Simplified77.3%
associate-/r*77.1%
associate-*r*84.1%
associate-/r*93.3%
div-inv93.2%
associate-/l/93.2%
*-commutative93.2%
associate-*r*80.0%
*-commutative80.0%
associate-*l*93.2%
Applied egg-rr93.2%
unpow-193.2%
associate-*l/93.2%
*-lft-identity93.2%
unpow-193.2%
Simplified93.2%
Final simplification95.0%
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 6.8e+140) (/ (/ 1.0 x) (fma (* z y) z y)) (/ 1.0 (/ (* z x) (/ (/ 1.0 y) z)))))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 6.8e+140) {
tmp = (1.0 / x) / fma((z * y), z, y);
} else {
tmp = 1.0 / ((z * x) / ((1.0 / y) / z));
}
return tmp;
}
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 6.8e+140) tmp = Float64(Float64(1.0 / x) / fma(Float64(z * y), z, y)); else tmp = Float64(1.0 / Float64(Float64(z * x) / Float64(Float64(1.0 / y) / 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[z, 6.8e+140], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(z * y), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(z * x), $MachinePrecision] / N[(N[(1.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 6.8 \cdot 10^{+140}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(z \cdot y, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z \cdot x}{\frac{\frac{1}{y}}{z}}}\\
\end{array}
\end{array}
if z < 6.8e140Initial program 94.7%
Taylor expanded in y around 0 94.7%
unpow294.7%
distribute-lft-in94.7%
+-commutative94.7%
*-rgt-identity94.7%
associate-*r*95.6%
fma-udef95.6%
Simplified95.6%
if 6.8e140 < z Initial program 71.4%
associate-/l/71.3%
associate-*l*71.3%
*-commutative71.3%
sqr-neg71.3%
+-commutative71.3%
sqr-neg71.3%
fma-def71.3%
Simplified71.3%
Taylor expanded in z around inf 71.3%
unpow271.3%
Simplified71.3%
/-rgt-identity71.3%
*-commutative71.3%
associate-/l*71.3%
associate-*r*80.8%
associate-/l*96.6%
Applied egg-rr96.6%
Final simplification95.7%
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) 1e+40) (/ 1.0 (* y (+ x (* x (* z z))))) (/ (/ 1.0 z) (* x (* z y)))))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+40) {
tmp = 1.0 / (y * (x + (x * (z * z))));
} else {
tmp = (1.0 / z) / (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 * z) <= 1d+40) then
tmp = 1.0d0 / (y * (x + (x * (z * z))))
else
tmp = (1.0d0 / z) / (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 * z) <= 1e+40) {
tmp = 1.0 / (y * (x + (x * (z * z))));
} else {
tmp = (1.0 / z) / (x * (z * y));
}
return tmp;
}
z = abs(z) [x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 1e+40: tmp = 1.0 / (y * (x + (x * (z * z)))) else: tmp = (1.0 / z) / (x * (z * y)) return tmp
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e+40) tmp = Float64(1.0 / Float64(y * Float64(x + Float64(x * Float64(z * z))))); else tmp = Float64(Float64(1.0 / z) / 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 * z) <= 1e+40)
tmp = 1.0 / (y * (x + (x * (z * z))));
else
tmp = (1.0 / z) / (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[N[(z * z), $MachinePrecision], 1e+40], N[(1.0 / N[(y * N[(x + N[(x * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / 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 \cdot z \leq 10^{+40}:\\
\;\;\;\;\frac{1}{y \cdot \left(x + x \cdot \left(z \cdot z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.00000000000000003e40Initial program 99.7%
associate-/l/99.7%
associate-*l*99.7%
*-commutative99.7%
sqr-neg99.7%
+-commutative99.7%
sqr-neg99.7%
fma-def99.7%
Simplified99.7%
fma-udef99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
Applied egg-rr99.7%
if 1.00000000000000003e40 < (*.f64 z z) Initial program 82.1%
associate-/l/80.7%
associate-*l*78.3%
*-commutative78.3%
sqr-neg78.3%
+-commutative78.3%
sqr-neg78.3%
fma-def78.3%
Simplified78.3%
Taylor expanded in z around inf 78.3%
unpow278.3%
Simplified78.3%
associate-/r*78.4%
associate-*r*83.5%
associate-/r*92.5%
div-inv92.5%
associate-/l/92.5%
*-commutative92.5%
associate-*r*88.8%
*-commutative88.8%
associate-*l*96.4%
Applied egg-rr96.4%
unpow-196.4%
associate-*l/96.4%
*-lft-identity96.4%
unpow-196.4%
Simplified96.4%
Final simplification98.3%
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+281) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (/ 1.0 (/ (* z x) (/ (/ 1.0 y) z)))))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+281) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = 1.0 / ((z * x) / ((1.0 / y) / 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+281) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = 1.0d0 / ((z * x) / ((1.0d0 / y) / 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+281) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = 1.0 / ((z * x) / ((1.0 / y) / z));
}
return tmp;
}
z = abs(z) [x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e+281: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = 1.0 / ((z * x) / ((1.0 / y) / z)) return tmp
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+281) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(1.0 / Float64(Float64(z * x) / Float64(Float64(1.0 / y) / 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+281)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = 1.0 / ((z * x) / ((1.0 / y) / 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+281], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(z * x), $MachinePrecision] / N[(N[(1.0 / y), $MachinePrecision] / 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^{+281}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z \cdot x}{\frac{\frac{1}{y}}{z}}}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.0000000000000001e281Initial program 98.2%
if 2.0000000000000001e281 < (*.f64 z z) Initial program 72.5%
associate-/l/72.5%
associate-*l*72.5%
*-commutative72.5%
sqr-neg72.5%
+-commutative72.5%
sqr-neg72.5%
fma-def72.5%
Simplified72.5%
Taylor expanded in z around inf 72.5%
unpow272.5%
Simplified72.5%
/-rgt-identity72.5%
*-commutative72.5%
associate-/l*72.5%
associate-*r*81.7%
associate-/l*96.8%
Applied egg-rr96.8%
Final simplification97.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 z) 5e-5) (/ 1.0 (* x y)) (/ 1.0 (* x (* z (* z y))))))
z = abs(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 * (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 * z) <= 5d-5) then
tmp = 1.0d0 / (x * y)
else
tmp = 1.0d0 / (x * (z * (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 * z) <= 5e-5) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / (x * (z * (z * y)));
}
return tmp;
}
z = abs(z) [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 * (z * y))) return tmp
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(1.0 / Float64(x * Float64(z * 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 * z) <= 5e-5)
tmp = 1.0 / (x * y);
else
tmp = 1.0 / (x * (z * (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[N[(z * z), $MachinePrecision], 5e-5], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.7%
associate-/l/99.8%
associate-*l*99.8%
*-commutative99.8%
sqr-neg99.8%
+-commutative99.8%
sqr-neg99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 99.3%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 84.0%
associate-/l/82.7%
associate-*l*80.6%
*-commutative80.6%
sqr-neg80.6%
+-commutative80.6%
sqr-neg80.6%
fma-def80.6%
Simplified80.6%
fma-udef80.6%
distribute-lft-in80.6%
*-rgt-identity80.6%
Applied egg-rr80.6%
Taylor expanded in z around inf 81.7%
unpow281.7%
associate-*r*86.9%
Simplified86.9%
Final simplification93.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 z) 5e-5) (/ 1.0 (* x y)) (/ 1.0 (* z (* z (* x y))))))
z = abs(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 * (z * (x * 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 * z) <= 5d-5) then
tmp = 1.0d0 / (x * y)
else
tmp = 1.0d0 / (z * (z * (x * 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 * z) <= 5e-5) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / (z * (z * (x * y)));
}
return tmp;
}
z = abs(z) [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 * (z * (x * y))) return tmp
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(1.0 / Float64(z * Float64(z * Float64(x * 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 * z) <= 5e-5)
tmp = 1.0 / (x * y);
else
tmp = 1.0 / (z * (z * (x * 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[N[(z * z), $MachinePrecision], 5e-5], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z * N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(x \cdot y\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.7%
associate-/l/99.8%
associate-*l*99.8%
*-commutative99.8%
sqr-neg99.8%
+-commutative99.8%
sqr-neg99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 99.3%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 84.0%
associate-/l/82.7%
associate-*l*80.6%
*-commutative80.6%
sqr-neg80.6%
+-commutative80.6%
sqr-neg80.6%
fma-def80.6%
Simplified80.6%
fma-udef80.6%
distribute-lft-in80.6%
*-rgt-identity80.6%
Applied egg-rr80.6%
Taylor expanded in z around inf 81.7%
unpow281.7%
associate-*r*86.9%
Simplified86.9%
/-rgt-identity86.9%
frac-2neg86.9%
neg-sub086.1%
metadata-eval86.1%
div-sub86.9%
metadata-eval86.1%
remove-double-div85.3%
associate-/r*85.4%
clear-num86.1%
associate-/l*92.0%
associate-/r*90.5%
metadata-eval90.5%
distribute-neg-frac90.5%
associate-/r*90.5%
*-commutative90.5%
mul-1-neg90.5%
remove-double-neg90.5%
frac-2neg90.5%
metadata-eval90.5%
associate-/r/90.6%
/-rgt-identity90.6%
neg-mul-190.6%
associate-*r*90.6%
Applied egg-rr85.9%
sub0-neg87.6%
distribute-rgt-neg-in87.6%
distribute-rgt-neg-out87.6%
remove-double-neg87.6%
*-commutative87.6%
Simplified87.6%
Final simplification93.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) 5e-5) (/ 1.0 (* x y)) (/ 1.0 (* (* z y) (* z x)))))
z = abs(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) * (z * x));
}
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) <= 5d-5) then
tmp = 1.0d0 / (x * y)
else
tmp = 1.0d0 / ((z * y) * (z * x))
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) <= 5e-5) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / ((z * y) * (z * x));
}
return tmp;
}
z = abs(z) [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) * (z * x)) return tmp
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(1.0 / Float64(Float64(z * y) * Float64(z * x))); 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) <= 5e-5)
tmp = 1.0 / (x * y);
else
tmp = 1.0 / ((z * y) * (z * x));
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], 5e-5], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(z * y), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(z \cdot y\right) \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.7%
associate-/l/99.8%
associate-*l*99.8%
*-commutative99.8%
sqr-neg99.8%
+-commutative99.8%
sqr-neg99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 99.3%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 84.0%
associate-/l/82.7%
associate-*l*80.6%
*-commutative80.6%
sqr-neg80.6%
+-commutative80.6%
sqr-neg80.6%
fma-def80.6%
Simplified80.6%
fma-udef80.6%
distribute-lft-in80.6%
*-rgt-identity80.6%
Applied egg-rr80.6%
+-commutative80.6%
distribute-lft-in80.6%
/-rgt-identity80.6%
associate-/r/80.6%
frac-2neg80.6%
/-rgt-identity80.6%
associate-/r/80.6%
associate-/r*81.3%
associate-/r*85.9%
associate-/l*93.9%
frac-add76.6%
associate-/r*76.6%
distribute-neg-frac76.6%
metadata-eval76.6%
distribute-neg-frac76.6%
metadata-eval76.6%
associate-/r*76.5%
Applied egg-rr76.5%
associate-*r/76.5%
*-rgt-identity76.5%
associate-/r/81.3%
Simplified81.3%
Taylor expanded in z around inf 91.4%
Final simplification95.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 (if (<= (* z z) 5e-5) (/ 1.0 (* x y)) (/ (/ 1.0 z) (* x (* z y)))))
z = abs(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) / (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 * z) <= 5d-5) then
tmp = 1.0d0 / (x * y)
else
tmp = (1.0d0 / z) / (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 * z) <= 5e-5) {
tmp = 1.0 / (x * y);
} else {
tmp = (1.0 / z) / (x * (z * y));
}
return tmp;
}
z = abs(z) [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) / (x * (z * y)) return tmp
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-5) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(Float64(1.0 / z) / 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 * z) <= 5e-5)
tmp = 1.0 / (x * y);
else
tmp = (1.0 / z) / (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[N[(z * z), $MachinePrecision], 5e-5], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / 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 \cdot z \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000024e-5Initial program 99.7%
associate-/l/99.8%
associate-*l*99.8%
*-commutative99.8%
sqr-neg99.8%
+-commutative99.8%
sqr-neg99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 99.3%
if 5.00000000000000024e-5 < (*.f64 z z) Initial program 84.0%
associate-/l/82.7%
associate-*l*80.6%
*-commutative80.6%
sqr-neg80.6%
+-commutative80.6%
sqr-neg80.6%
fma-def80.6%
Simplified80.6%
Taylor expanded in z around inf 79.5%
unpow279.5%
Simplified79.5%
associate-/r*79.6%
associate-*r*84.1%
associate-/r*92.2%
div-inv92.2%
associate-/l/92.1%
*-commutative92.1%
associate-*r*88.8%
*-commutative88.8%
associate-*l*95.6%
Applied egg-rr95.6%
unpow-195.6%
associate-*l/95.6%
*-lft-identity95.6%
unpow-195.6%
Simplified95.6%
Final simplification97.5%
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 0.3) (/ 1.0 (* x y)) (/ 1.0 (* x (* y (* z z))))))
z = abs(z);
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 0.3) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / (x * (y * (z * 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 <= 0.3d0) then
tmp = 1.0d0 / (x * y)
else
tmp = 1.0d0 / (x * (y * (z * 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 <= 0.3) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / (x * (y * (z * z)));
}
return tmp;
}
z = abs(z) [x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 0.3: tmp = 1.0 / (x * y) else: tmp = 1.0 / (x * (y * (z * z))) return tmp
z = abs(z) x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 0.3) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(1.0 / Float64(x * Float64(y * Float64(z * 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 <= 0.3)
tmp = 1.0 / (x * y);
else
tmp = 1.0 / (x * (y * (z * 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, 0.3], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.3:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(y \cdot \left(z \cdot z\right)\right)}\\
\end{array}
\end{array}
if z < 0.299999999999999989Initial program 94.8%
associate-/l/94.4%
associate-*l*92.5%
*-commutative92.5%
sqr-neg92.5%
+-commutative92.5%
sqr-neg92.5%
fma-def92.5%
Simplified92.5%
Taylor expanded in z around 0 79.4%
if 0.299999999999999989 < z Initial program 84.1%
associate-/l/82.8%
associate-*l*84.3%
*-commutative84.3%
sqr-neg84.3%
+-commutative84.3%
sqr-neg84.3%
fma-def84.3%
Simplified84.3%
Taylor expanded in z around inf 80.8%
associate-*r*80.5%
unpow280.5%
associate-*r*80.8%
Simplified80.8%
Final simplification79.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 (/ 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 92.0%
associate-/l/91.4%
associate-*l*90.3%
*-commutative90.3%
sqr-neg90.3%
+-commutative90.3%
sqr-neg90.3%
fma-def90.3%
Simplified90.3%
Taylor expanded in z around 0 65.2%
Final simplification65.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 2023297
(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)))))