
(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+43) (/ 1.0 (* x (* y (fma z z 1.0)))) (/ (/ 1.0 (* x z)) (* z y))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+43) {
tmp = 1.0 / (x * (y * fma(z, z, 1.0)));
} else {
tmp = (1.0 / (x * z)) / (z * y);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+43) tmp = Float64(1.0 / Float64(x * Float64(y * fma(z, z, 1.0)))); else tmp = Float64(Float64(1.0 / Float64(x * z)) / Float64(z * y)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+43], N[(1.0 / N[(x * N[(y * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+43}:\\
\;\;\;\;\frac{1}{x \cdot \left(y \cdot \mathsf{fma}\left(z, z, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000004e43Initial program 99.6%
associate-/r*99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
if 5.0000000000000004e43 < (*.f64 z z) Initial program 62.0%
associate-/r*62.0%
+-commutative62.0%
fma-def62.0%
Simplified62.0%
fma-udef62.0%
+-commutative62.0%
associate-/r*62.0%
associate-/r*45.2%
add-sqr-sqrt45.2%
*-un-lft-identity45.2%
times-frac45.2%
hypot-1-def45.2%
hypot-1-def63.9%
Applied egg-rr63.9%
associate-*l/64.0%
*-lft-identity64.0%
associate-/l/92.1%
*-rgt-identity92.1%
associate-*r/91.9%
associate-/l/92.0%
associate-*l/99.4%
associate-/l/99.4%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l/99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in z around inf 50.1%
Taylor expanded in z around inf 99.5%
Final simplification99.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ (/ 1.0 x) (hypot 1.0 z)) (* (hypot 1.0 z) y)))
assert(x < y);
double code(double x, double y, double z) {
return ((1.0 / x) / hypot(1.0, z)) / (hypot(1.0, z) * y);
}
assert x < y;
public static double code(double x, double y, double z) {
return ((1.0 / x) / Math.hypot(1.0, z)) / (Math.hypot(1.0, z) * y);
}
[x, y] = sort([x, y]) def code(x, y, z): return ((1.0 / x) / math.hypot(1.0, z)) / (math.hypot(1.0, z) * y)
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(Float64(1.0 / x) / hypot(1.0, z)) / Float64(hypot(1.0, z) * y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = ((1.0 / x) / hypot(1.0, z)) / (hypot(1.0, z) * y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(N[(1.0 / x), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right) \cdot y}
\end{array}
Initial program 85.0%
associate-/r*85.1%
+-commutative85.1%
fma-def85.1%
Simplified85.1%
fma-udef85.1%
+-commutative85.1%
associate-/r*85.0%
associate-/r*78.2%
add-sqr-sqrt78.2%
*-un-lft-identity78.2%
times-frac78.2%
hypot-1-def78.2%
hypot-1-def85.4%
Applied egg-rr85.4%
associate-*l/85.4%
*-lft-identity85.4%
associate-/l/96.7%
*-rgt-identity96.7%
associate-*r/96.6%
associate-/l/96.6%
associate-*l/99.5%
associate-/l/99.5%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l/99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
expm1-log1p-u56.6%
expm1-udef41.2%
Applied egg-rr41.2%
expm1-def56.6%
expm1-log1p99.5%
associate-/r*99.5%
Simplified99.5%
Final simplification99.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 (* x (hypot 1.0 z))) (* (hypot 1.0 z) y)))
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / (x * hypot(1.0, z))) / (hypot(1.0, z) * y);
}
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / (x * Math.hypot(1.0, z))) / (Math.hypot(1.0, z) * y);
}
[x, y] = sort([x, y]) def code(x, y, z): return (1.0 / (x * math.hypot(1.0, z))) / (math.hypot(1.0, z) * y)
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / Float64(x * hypot(1.0, z))) / Float64(hypot(1.0, z) * y)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / (x * hypot(1.0, z))) / (hypot(1.0, z) * y);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / N[(x * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{x \cdot \mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right) \cdot y}
\end{array}
Initial program 85.0%
associate-/r*85.1%
+-commutative85.1%
fma-def85.1%
Simplified85.1%
fma-udef85.1%
+-commutative85.1%
associate-/r*85.0%
associate-/r*78.2%
add-sqr-sqrt78.2%
*-un-lft-identity78.2%
times-frac78.2%
hypot-1-def78.2%
hypot-1-def85.4%
Applied egg-rr85.4%
associate-*l/85.4%
*-lft-identity85.4%
associate-/l/96.7%
*-rgt-identity96.7%
associate-*r/96.6%
associate-/l/96.6%
associate-*l/99.5%
associate-/l/99.5%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l/99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 400.0) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (/ (/ 1.0 (* x z)) (* z y))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 400.0) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / (x * z)) / (z * y);
}
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) <= 400.0d0) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = (1.0d0 / (x * z)) / (z * y)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 400.0) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / (x * z)) / (z * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 400.0: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = (1.0 / (x * z)) / (z * y) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 400.0) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(1.0 / Float64(x * z)) / Float64(z * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 400.0)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = (1.0 / (x * z)) / (z * y);
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], 400.0], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 400:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\
\end{array}
\end{array}
if (*.f64 z z) < 400Initial program 99.6%
if 400 < (*.f64 z z) Initial program 63.8%
associate-/r*63.8%
+-commutative63.8%
fma-def63.8%
Simplified63.8%
fma-udef63.8%
+-commutative63.8%
associate-/r*63.8%
associate-/r*47.0%
add-sqr-sqrt47.0%
*-un-lft-identity47.0%
times-frac46.9%
hypot-1-def46.9%
hypot-1-def64.8%
Applied egg-rr64.8%
associate-*l/64.8%
*-lft-identity64.8%
associate-/l/92.4%
*-rgt-identity92.4%
associate-*r/92.3%
associate-/l/92.4%
associate-*l/99.5%
associate-/l/99.4%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l/99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in z around inf 50.6%
Taylor expanded in z around inf 99.5%
Final simplification99.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e-11) (/ 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) <= 2e-11) {
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) <= 2d-11) 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) <= 2e-11) {
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) <= 2e-11: 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) <= 2e-11) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(1.0 / Float64(y * Float64(x * 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-11)
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], 2e-11], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(y * N[(x * 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^{-11}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(x \cdot \left(z \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.99999999999999988e-11Initial program 99.6%
associate-/r*99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around 0 99.5%
if 1.99999999999999988e-11 < (*.f64 z z) Initial program 64.1%
associate-/r*64.2%
+-commutative64.2%
fma-def64.2%
Simplified64.2%
fma-udef64.2%
+-commutative64.2%
associate-/r*64.1%
associate-/r*47.5%
add-sqr-sqrt47.5%
*-un-lft-identity47.5%
times-frac47.4%
hypot-1-def47.4%
hypot-1-def65.1%
Applied egg-rr65.1%
associate-*l/65.1%
*-lft-identity65.1%
associate-/l/92.5%
*-rgt-identity92.5%
associate-*r/92.3%
associate-/l/92.4%
associate-*l/99.5%
associate-/l/99.4%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l/99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in z around inf 63.5%
unpow263.5%
*-commutative63.5%
Simplified63.5%
Final simplification84.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e-11) (/ 1.0 (* x y)) (/ 1.0 (* y (* z (* x z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-11) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / (y * (z * (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-11) then
tmp = 1.0d0 / (x * y)
else
tmp = 1.0d0 / (y * (z * (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-11) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / (y * (z * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e-11: tmp = 1.0 / (x * y) else: tmp = 1.0 / (y * (z * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e-11) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(1.0 / Float64(y * Float64(z * 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) <= 2e-11)
tmp = 1.0 / (x * y);
else
tmp = 1.0 / (y * (z * (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-11], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(y * N[(z * 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 2 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(x \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.99999999999999988e-11Initial program 99.6%
associate-/r*99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around 0 99.5%
if 1.99999999999999988e-11 < (*.f64 z z) Initial program 64.1%
associate-/r*64.2%
+-commutative64.2%
fma-def64.2%
Simplified64.2%
Taylor expanded in z around inf 63.5%
unpow263.5%
*-commutative63.5%
associate-*r*86.2%
Simplified86.2%
Final simplification94.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-11) (/ 1.0 (* x y)) (/ (/ 1.0 y) (* z (* x z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-11) {
tmp = 1.0 / (x * y);
} else {
tmp = (1.0 / y) / (z * (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-11) then
tmp = 1.0d0 / (x * y)
else
tmp = (1.0d0 / y) / (z * (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-11) {
tmp = 1.0 / (x * y);
} else {
tmp = (1.0 / y) / (z * (x * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e-11: tmp = 1.0 / (x * y) else: tmp = (1.0 / y) / (z * (x * z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e-11) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(Float64(1.0 / y) / Float64(z * 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) <= 2e-11)
tmp = 1.0 / (x * y);
else
tmp = (1.0 / y) / (z * (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-11], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] / N[(z * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.99999999999999988e-11Initial program 99.6%
associate-/r*99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around 0 99.5%
if 1.99999999999999988e-11 < (*.f64 z z) Initial program 64.1%
associate-/r*64.2%
+-commutative64.2%
fma-def64.2%
Simplified64.2%
fma-udef64.2%
+-commutative64.2%
associate-/r*64.1%
associate-/r*47.5%
add-sqr-sqrt47.5%
*-un-lft-identity47.5%
times-frac47.4%
hypot-1-def47.4%
hypot-1-def65.1%
Applied egg-rr65.1%
associate-*l/65.1%
*-lft-identity65.1%
associate-/l/92.5%
*-rgt-identity92.5%
associate-*r/92.3%
associate-/l/92.4%
associate-*l/99.5%
associate-/l/99.4%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l/99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
expm1-log1p-u77.7%
expm1-udef43.1%
Applied egg-rr43.1%
expm1-def77.7%
expm1-log1p99.5%
associate-/r*99.5%
Simplified99.5%
Taylor expanded in z around inf 63.5%
associate-/r*63.5%
unpow263.5%
associate-*l*86.4%
Simplified86.4%
Final simplification94.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-11) (/ 1.0 (* x y)) (/ (/ 1.0 (* x z)) (* z y))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-11) {
tmp = 1.0 / (x * y);
} else {
tmp = (1.0 / (x * z)) / (z * y);
}
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-11) then
tmp = 1.0d0 / (x * y)
else
tmp = (1.0d0 / (x * z)) / (z * y)
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-11) {
tmp = 1.0 / (x * y);
} else {
tmp = (1.0 / (x * z)) / (z * y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e-11: tmp = 1.0 / (x * y) else: tmp = (1.0 / (x * z)) / (z * y) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e-11) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(Float64(1.0 / Float64(x * z)) / Float64(z * y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e-11)
tmp = 1.0 / (x * y);
else
tmp = (1.0 / (x * z)) / (z * y);
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-11], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot z}}{z \cdot y}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.99999999999999988e-11Initial program 99.6%
associate-/r*99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around 0 99.5%
if 1.99999999999999988e-11 < (*.f64 z z) Initial program 64.1%
associate-/r*64.2%
+-commutative64.2%
fma-def64.2%
Simplified64.2%
fma-udef64.2%
+-commutative64.2%
associate-/r*64.1%
associate-/r*47.5%
add-sqr-sqrt47.5%
*-un-lft-identity47.5%
times-frac47.4%
hypot-1-def47.4%
hypot-1-def65.1%
Applied egg-rr65.1%
associate-*l/65.1%
*-lft-identity65.1%
associate-/l/92.5%
*-rgt-identity92.5%
associate-*r/92.3%
associate-/l/92.4%
associate-*l/99.5%
associate-/l/99.4%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l/99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in z around inf 50.4%
Taylor expanded in z around inf 98.9%
Final simplification99.3%
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(1.0 / Float64(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[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{x \cdot y}
\end{array}
Initial program 85.0%
associate-/r*85.1%
+-commutative85.1%
fma-def85.1%
Simplified85.1%
Taylor expanded in z around 0 63.3%
Final simplification63.3%
(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 2023278
(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)))))