
(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 (<= y 4e-151) (/ (/ 1.0 x) (fma (* y z) z y)) (* (/ 1.0 (hypot 1.0 z)) (/ (/ (/ 1.0 y) x) (hypot 1.0 z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (y <= 4e-151) {
tmp = (1.0 / x) / fma((y * z), z, y);
} else {
tmp = (1.0 / hypot(1.0, z)) * (((1.0 / y) / x) / hypot(1.0, z));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (y <= 4e-151) tmp = Float64(Float64(1.0 / x) / fma(Float64(y * z), z, y)); else tmp = Float64(Float64(1.0 / hypot(1.0, z)) * Float64(Float64(Float64(1.0 / y) / x) / hypot(1.0, z))); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 4e-151], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-151}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{\frac{1}{y}}{x}}{\mathsf{hypot}\left(1, z\right)}\\
\end{array}
\end{array}
if y < 3.9999999999999998e-151Initial program 92.0%
distribute-lft-in92.0%
*-rgt-identity92.0%
+-commutative92.0%
associate-*r*95.6%
fma-def95.6%
Applied egg-rr95.6%
if 3.9999999999999998e-151 < y Initial program 89.6%
associate-/r*89.4%
*-commutative89.4%
sqr-neg89.4%
+-commutative89.4%
distribute-lft1-in89.4%
*-commutative89.4%
fma-def89.4%
sqr-neg89.4%
Simplified89.4%
associate-/r*89.7%
fma-udef89.6%
*-rgt-identity89.6%
distribute-lft-in89.6%
+-commutative89.6%
associate-/r*91.7%
associate-/r*91.6%
*-un-lft-identity91.6%
+-commutative91.6%
fma-udef91.6%
add-sqr-sqrt91.5%
times-frac91.5%
fma-udef91.5%
+-commutative91.5%
hypot-1-def91.5%
*-commutative91.5%
associate-/r*91.7%
fma-udef91.7%
+-commutative91.7%
hypot-1-def98.5%
Applied egg-rr98.5%
Final simplification96.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+43) (/ 1.0 (* x (+ y (* y (* z z))))) (/ (/ 1.0 z) (* x (* y z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+43) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 2d+43) then
tmp = 1.0d0 / (x * (y + (y * (z * z))))
else
tmp = (1.0d0 / z) / (x * (y * z))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+43) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e+43: tmp = 1.0 / (x * (y + (y * (z * z)))) else: tmp = (1.0 / z) / (x * (y * z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+43) tmp = Float64(1.0 / Float64(x * Float64(y + Float64(y * Float64(z * z))))); else tmp = Float64(Float64(1.0 / z) / Float64(x * Float64(y * z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e+43)
tmp = 1.0 / (x * (y + (y * (z * z))));
else
tmp = (1.0 / z) / (x * (y * z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+43], N[(1.0 / N[(x * N[(y + N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(x * N[(y * 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^{+43}:\\
\;\;\;\;\frac{1}{x \cdot \left(y + y \cdot \left(z \cdot z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(y \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000003e43Initial program 99.4%
associate-/r*99.4%
*-commutative99.4%
sqr-neg99.4%
+-commutative99.4%
distribute-lft1-in99.5%
*-commutative99.5%
fma-def99.5%
sqr-neg99.5%
Simplified99.5%
fma-udef99.5%
Applied egg-rr99.5%
if 2.00000000000000003e43 < (*.f64 z z) Initial program 81.6%
associate-/r*81.7%
*-commutative81.7%
sqr-neg81.7%
+-commutative81.7%
distribute-lft1-in81.7%
*-commutative81.7%
fma-def81.7%
sqr-neg81.7%
Simplified81.7%
Taylor expanded in z around inf 81.7%
unpow281.7%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
frac-2neg81.5%
metadata-eval81.5%
div-inv81.5%
associate-*r*89.5%
distribute-rgt-neg-in89.5%
*-commutative89.5%
associate-*l*95.7%
Applied egg-rr95.7%
associate-*r/95.7%
metadata-eval95.7%
*-commutative95.7%
associate-/r*97.6%
neg-mul-197.6%
associate-/r*97.6%
metadata-eval97.6%
Simplified97.6%
Final simplification98.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+43) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (/ (/ 1.0 z) (* x (* y z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+43) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 2d+43) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
else
tmp = (1.0d0 / z) / (x * (y * z))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+43) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e+43: tmp = (1.0 / x) / (y * (1.0 + (z * z))) else: tmp = (1.0 / z) / (x * (y * z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+43) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(1.0 / z) / Float64(x * Float64(y * z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e+43)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
else
tmp = (1.0 / z) / (x * (y * z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+43], 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[(x * N[(y * 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^{+43}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(y \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000003e43Initial program 99.4%
if 2.00000000000000003e43 < (*.f64 z z) Initial program 81.6%
associate-/r*81.7%
*-commutative81.7%
sqr-neg81.7%
+-commutative81.7%
distribute-lft1-in81.7%
*-commutative81.7%
fma-def81.7%
sqr-neg81.7%
Simplified81.7%
Taylor expanded in z around inf 81.7%
unpow281.7%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
frac-2neg81.5%
metadata-eval81.5%
div-inv81.5%
associate-*r*89.5%
distribute-rgt-neg-in89.5%
*-commutative89.5%
associate-*l*95.7%
Applied egg-rr95.7%
associate-*r/95.7%
metadata-eval95.7%
*-commutative95.7%
associate-/r*97.6%
neg-mul-197.6%
associate-/r*97.6%
metadata-eval97.6%
Simplified97.6%
Final simplification98.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+43) (/ (/ 1.0 x) (+ y (* y (* z z)))) (/ (/ 1.0 z) (* x (* y z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+43) {
tmp = (1.0 / x) / (y + (y * (z * z)));
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 2d+43) then
tmp = (1.0d0 / x) / (y + (y * (z * z)))
else
tmp = (1.0d0 / z) / (x * (y * z))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+43) {
tmp = (1.0 / x) / (y + (y * (z * z)));
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 2e+43: tmp = (1.0 / x) / (y + (y * (z * z))) else: tmp = (1.0 / z) / (x * (y * z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+43) tmp = Float64(Float64(1.0 / x) / Float64(y + Float64(y * Float64(z * z)))); else tmp = Float64(Float64(1.0 / z) / Float64(x * Float64(y * z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 2e+43)
tmp = (1.0 / x) / (y + (y * (z * z)));
else
tmp = (1.0 / z) / (x * (y * z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+43], N[(N[(1.0 / x), $MachinePrecision] / N[(y + N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(x * N[(y * 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^{+43}:\\
\;\;\;\;\frac{\frac{1}{x}}{y + y \cdot \left(z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(y \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000003e43Initial program 99.4%
distribute-lft-in99.5%
*-rgt-identity99.5%
+-commutative99.5%
associate-*r*99.5%
fma-def99.5%
Applied egg-rr99.5%
fma-udef99.5%
associate-*l*99.5%
Applied egg-rr99.5%
if 2.00000000000000003e43 < (*.f64 z z) Initial program 81.6%
associate-/r*81.7%
*-commutative81.7%
sqr-neg81.7%
+-commutative81.7%
distribute-lft1-in81.7%
*-commutative81.7%
fma-def81.7%
sqr-neg81.7%
Simplified81.7%
Taylor expanded in z around inf 81.7%
unpow281.7%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
frac-2neg81.5%
metadata-eval81.5%
div-inv81.5%
associate-*r*89.5%
distribute-rgt-neg-in89.5%
*-commutative89.5%
associate-*l*95.7%
Applied egg-rr95.7%
associate-*r/95.7%
metadata-eval95.7%
*-commutative95.7%
associate-/r*97.6%
neg-mul-197.6%
associate-/r*97.6%
metadata-eval97.6%
Simplified97.6%
Final simplification98.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1.0) (/ (/ 1.0 x) y) (/ 1.0 (* x (* y (* z z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (y * (z * z)));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 1.0d0) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (x * (y * (z * z)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1.0) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (y * (z * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 1.0: tmp = (1.0 / x) / y else: tmp = 1.0 / (x * (y * (z * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1.0) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(x * Float64(y * Float64(z * z)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 1.0)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (x * (y * (z * z)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1.0], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(x * N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 1:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(y \cdot \left(z \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1Initial program 99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
+-commutative99.5%
associate-*r*99.5%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 97.6%
if 1 < (*.f64 z z) Initial program 83.3%
associate-/r*83.4%
*-commutative83.4%
sqr-neg83.4%
+-commutative83.4%
distribute-lft1-in83.4%
*-commutative83.4%
fma-def83.4%
sqr-neg83.4%
Simplified83.4%
Taylor expanded in z around inf 81.3%
unpow281.3%
Simplified81.3%
Final simplification89.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1.0) (/ (/ 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) <= 1.0) {
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) <= 1.0d0) 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) <= 1.0) {
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) <= 1.0: 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) <= 1.0) tmp = Float64(Float64(1.0 / 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) <= 1.0)
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], 1.0], N[(N[(1.0 / x), $MachinePrecision] / y), $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 1:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(x \cdot \left(z \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1Initial program 99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
+-commutative99.5%
associate-*r*99.5%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 97.6%
if 1 < (*.f64 z z) Initial program 83.3%
associate-/r*83.4%
*-commutative83.4%
sqr-neg83.4%
+-commutative83.4%
distribute-lft1-in83.4%
*-commutative83.4%
fma-def83.4%
sqr-neg83.4%
Simplified83.4%
Taylor expanded in z around inf 81.3%
unpow281.3%
associate-*r*80.5%
*-commutative80.5%
associate-*l*79.1%
Simplified79.1%
Final simplification88.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 0.75) (/ (- 1.0 (* z z)) (* y x)) (/ 1.0 (* y (* x (* z z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.75) {
tmp = (1.0 - (z * z)) / (y * x);
} 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) <= 0.75d0) then
tmp = (1.0d0 - (z * z)) / (y * x)
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) <= 0.75) {
tmp = (1.0 - (z * z)) / (y * x);
} 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) <= 0.75: tmp = (1.0 - (z * z)) / (y * x) 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) <= 0.75) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y * x)); 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) <= 0.75)
tmp = (1.0 - (z * z)) / (y * x);
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], 0.75], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * x), $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 0.75:\\
\;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(x \cdot \left(z \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.75Initial program 99.5%
associate-/r*99.5%
*-commutative99.5%
sqr-neg99.5%
+-commutative99.5%
distribute-lft1-in99.5%
*-commutative99.5%
fma-def99.5%
sqr-neg99.5%
Simplified99.5%
Taylor expanded in z around 0 83.6%
associate-/l/83.8%
+-commutative83.8%
mul-1-neg83.8%
unsub-neg83.8%
associate-/r*83.6%
unpow283.6%
*-commutative83.6%
div-sub98.3%
Simplified98.3%
if 0.75 < (*.f64 z z) Initial program 83.3%
associate-/r*83.4%
*-commutative83.4%
sqr-neg83.4%
+-commutative83.4%
distribute-lft1-in83.4%
*-commutative83.4%
fma-def83.4%
sqr-neg83.4%
Simplified83.4%
Taylor expanded in z around inf 81.3%
unpow281.3%
associate-*r*80.5%
*-commutative80.5%
associate-*l*79.1%
Simplified79.1%
Final simplification88.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 0.2) (/ (- 1.0 (* z z)) (* y x)) (/ (/ 1.0 z) (* x (* y z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.2) {
tmp = (1.0 - (z * z)) / (y * x);
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 0.2d0) then
tmp = (1.0d0 - (z * z)) / (y * x)
else
tmp = (1.0d0 / z) / (x * (y * z))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.2) {
tmp = (1.0 - (z * z)) / (y * x);
} else {
tmp = (1.0 / z) / (x * (y * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 0.2: tmp = (1.0 - (z * z)) / (y * x) else: tmp = (1.0 / z) / (x * (y * z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 0.2) tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(y * x)); else tmp = Float64(Float64(1.0 / z) / Float64(x * Float64(y * z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 0.2)
tmp = (1.0 - (z * z)) / (y * x);
else
tmp = (1.0 / z) / (x * (y * z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 0.2], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.2:\\
\;\;\;\;\frac{1 - z \cdot z}{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(y \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.20000000000000001Initial program 99.5%
associate-/r*99.5%
*-commutative99.5%
sqr-neg99.5%
+-commutative99.5%
distribute-lft1-in99.5%
*-commutative99.5%
fma-def99.5%
sqr-neg99.5%
Simplified99.5%
Taylor expanded in z around 0 83.6%
associate-/l/83.8%
+-commutative83.8%
mul-1-neg83.8%
unsub-neg83.8%
associate-/r*83.6%
unpow283.6%
*-commutative83.6%
div-sub98.3%
Simplified98.3%
if 0.20000000000000001 < (*.f64 z z) Initial program 83.3%
associate-/r*83.4%
*-commutative83.4%
sqr-neg83.4%
+-commutative83.4%
distribute-lft1-in83.4%
*-commutative83.4%
fma-def83.4%
sqr-neg83.4%
Simplified83.4%
Taylor expanded in z around inf 81.3%
unpow281.3%
associate-*r*80.5%
*-commutative80.5%
Simplified80.5%
frac-2neg80.5%
metadata-eval80.5%
div-inv80.5%
associate-*r*87.7%
distribute-rgt-neg-in87.7%
*-commutative87.7%
associate-*l*93.9%
Applied egg-rr93.9%
associate-*r/93.9%
metadata-eval93.9%
*-commutative93.9%
associate-/r*95.6%
neg-mul-195.6%
associate-/r*95.6%
metadata-eval95.6%
Simplified95.6%
Final simplification96.9%
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.1%
associate-/r*91.1%
*-commutative91.1%
sqr-neg91.1%
+-commutative91.1%
distribute-lft1-in91.1%
*-commutative91.1%
fma-def91.1%
sqr-neg91.1%
Simplified91.1%
Taylor expanded in z around 0 56.2%
*-commutative56.2%
Simplified56.2%
Final simplification56.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 2023271
(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)))))