
(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: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y (+ 1.0 (* z z))) 5e+304) (/ (/ 1.0 (fma z (* y z) y)) x) (* (pow z -1.0) (/ 1.0 (* y (* z x))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+304) {
tmp = (1.0 / fma(z, (y * z), y)) / x;
} else {
tmp = pow(z, -1.0) * (1.0 / (y * (z * x)));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 5e+304) tmp = Float64(Float64(1.0 / fma(z, Float64(y * z), y)) / x); else tmp = Float64((z ^ -1.0) * Float64(1.0 / Float64(y * Float64(z * x)))); 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[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+304], N[(N[(1.0 / N[(z * N[(y * z), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Power[z, -1.0], $MachinePrecision] * N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+304}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{fma}\left(z, y \cdot z, y\right)}}{x}\\
\mathbf{else}:\\
\;\;\;\;{z}^{-1} \cdot \frac{1}{y \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 4.9999999999999997e304Initial program 95.6%
associate-/r*95.4%
+-commutative95.4%
fma-def95.4%
Simplified95.4%
Taylor expanded in x around 0 92.7%
associate-*r*95.4%
*-commutative95.4%
associate-*r*94.3%
associate-/r*94.5%
unpow294.5%
fma-udef94.5%
associate-/r*95.6%
associate-/l/95.6%
fma-udef95.6%
distribute-lft-in95.6%
*-rgt-identity95.6%
fma-def95.6%
fma-def95.6%
*-commutative95.6%
associate-*r*96.9%
fma-udef96.9%
Simplified96.9%
if 4.9999999999999997e304 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 64.0%
associate-/r*64.0%
+-commutative64.0%
fma-def64.0%
Simplified64.0%
Taylor expanded in z around inf 68.0%
*-commutative68.0%
unpow268.0%
associate-*r*67.7%
associate-*l*93.2%
*-commutative93.2%
associate-*l*95.8%
*-commutative95.8%
Simplified95.8%
associate-/r*95.8%
div-inv95.8%
inv-pow95.8%
*-commutative95.8%
*-commutative95.8%
associate-*l*99.7%
Applied egg-rr99.7%
Final simplification97.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (/ (/ 1.0 (* (* y (hypot 1.0 z)) x)) (hypot 1.0 z)))
assert(x < y);
double code(double x, double y, double z) {
return (1.0 / ((y * hypot(1.0, z)) * x)) / hypot(1.0, z);
}
assert x < y;
public static double code(double x, double y, double z) {
return (1.0 / ((y * Math.hypot(1.0, z)) * x)) / Math.hypot(1.0, z);
}
[x, y] = sort([x, y]) def code(x, y, z): return (1.0 / ((y * math.hypot(1.0, z)) * x)) / math.hypot(1.0, z)
x, y = sort([x, y]) function code(x, y, z) return Float64(Float64(1.0 / Float64(Float64(y * hypot(1.0, z)) * x)) / hypot(1.0, z)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z)
tmp = (1.0 / ((y * hypot(1.0, z)) * x)) / hypot(1.0, z);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(1.0 / N[(N[(y * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{\left(y \cdot \mathsf{hypot}\left(1, z\right)\right) \cdot x}}{\mathsf{hypot}\left(1, z\right)}
\end{array}
Initial program 89.8%
associate-/r*89.6%
+-commutative89.6%
fma-def89.6%
Simplified89.6%
associate-/r*89.8%
*-un-lft-identity89.8%
fma-udef89.8%
+-commutative89.8%
add-sqr-sqrt43.6%
times-frac43.5%
*-commutative43.5%
sqrt-prod43.5%
hypot-1-def43.5%
*-commutative43.5%
sqrt-prod44.3%
hypot-1-def50.1%
Applied egg-rr50.1%
associate-*l/50.1%
*-lft-identity50.1%
*-commutative50.1%
associate-/r*49.7%
associate-/r*49.4%
associate-/l/49.4%
rem-square-sqrt98.5%
associate-/r*97.6%
associate-/l/97.5%
*-commutative97.5%
Simplified97.5%
Final simplification97.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* y (+ 1.0 (* z z))) 5e+304) (/ (/ 1.0 (fma z (* y z) y)) x) (/ (/ 1.0 (* y (* z x))) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+304) {
tmp = (1.0 / fma(z, (y * z), y)) / x;
} 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(y * Float64(1.0 + Float64(z * z))) <= 5e+304) tmp = Float64(Float64(1.0 / fma(z, Float64(y * z), y)) / x); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * x))) / 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[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+304], N[(N[(1.0 / N[(z * N[(y * z), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+304}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{fma}\left(z, y \cdot z, y\right)}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 4.9999999999999997e304Initial program 95.6%
associate-/r*95.4%
+-commutative95.4%
fma-def95.4%
Simplified95.4%
Taylor expanded in x around 0 92.7%
associate-*r*95.4%
*-commutative95.4%
associate-*r*94.3%
associate-/r*94.5%
unpow294.5%
fma-udef94.5%
associate-/r*95.6%
associate-/l/95.6%
fma-udef95.6%
distribute-lft-in95.6%
*-rgt-identity95.6%
fma-def95.6%
fma-def95.6%
*-commutative95.6%
associate-*r*96.9%
fma-udef96.9%
Simplified96.9%
if 4.9999999999999997e304 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 64.0%
associate-/r*64.0%
+-commutative64.0%
fma-def64.0%
Simplified64.0%
Taylor expanded in z around inf 68.0%
*-commutative68.0%
unpow268.0%
associate-*r*67.7%
associate-*l*93.2%
*-commutative93.2%
associate-*l*95.8%
*-commutative95.8%
Simplified95.8%
expm1-log1p-u95.8%
expm1-udef65.1%
associate-*r*65.1%
*-commutative65.1%
associate-*r*65.1%
Applied egg-rr65.1%
expm1-def99.7%
expm1-log1p99.7%
associate-/r*99.7%
*-commutative99.7%
associate-/r*99.7%
unpow-199.7%
*-commutative99.7%
associate-/r*91.6%
unpow-191.6%
associate-/r*91.5%
Simplified91.5%
Taylor expanded in y around 0 99.7%
Final simplification97.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+67) (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) (/ (/ 1.0 (* y (* z x))) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+67) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} 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) <= 4d+67) then
tmp = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
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) <= 4e+67) {
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
} 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) <= 4e+67: tmp = (1.0 / x) / (y * (1.0 + (z * z))) 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) <= 4e+67) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * 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) <= 4e+67)
tmp = (1.0 / x) / (y * (1.0 + (z * z)));
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], 4e+67], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+67}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 3.99999999999999993e67Initial program 99.7%
if 3.99999999999999993e67 < (*.f64 z z) Initial program 79.1%
associate-/r*78.9%
+-commutative78.9%
fma-def78.9%
Simplified78.9%
Taylor expanded in z around inf 75.9%
*-commutative75.9%
unpow275.9%
associate-*r*78.3%
associate-*l*91.8%
*-commutative91.8%
associate-*l*94.9%
*-commutative94.9%
Simplified94.9%
expm1-log1p-u90.1%
expm1-udef58.9%
associate-*r*58.9%
*-commutative58.9%
associate-*r*58.9%
Applied egg-rr58.9%
expm1-def90.9%
expm1-log1p95.7%
associate-/r*96.7%
*-commutative96.7%
associate-/r*96.7%
unpow-196.7%
*-commutative96.7%
associate-/r*91.2%
unpow-191.2%
associate-/r*91.2%
Simplified91.2%
Taylor expanded in y around 0 96.7%
Final simplification98.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e+251) (/ (/ (/ 1.0 x) y) (+ 1.0 (* z z))) (/ (/ (/ 1.0 x) (* y z)) z)))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+251) {
tmp = ((1.0 / x) / y) / (1.0 + (z * z));
} 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) <= 5d+251) then
tmp = ((1.0d0 / x) / y) / (1.0d0 + (z * z))
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) <= 5e+251) {
tmp = ((1.0 / x) / y) / (1.0 + (z * z));
} 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) <= 5e+251: tmp = ((1.0 / x) / y) / (1.0 + (z * z)) 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) <= 5e+251) tmp = Float64(Float64(Float64(1.0 / x) / y) / Float64(1.0 + Float64(z * z))); else tmp = Float64(Float64(Float64(1.0 / x) / Float64(y * z)) / z); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 5e+251)
tmp = ((1.0 / x) / y) / (1.0 + (z * z));
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], 5e+251], N[(N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision] / N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+251}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{y \cdot z}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000005e251Initial program 98.5%
associate-/r*98.6%
Simplified98.6%
if 5.0000000000000005e251 < (*.f64 z z) Initial program 71.5%
associate-/r*71.6%
+-commutative71.6%
fma-def71.6%
Simplified71.6%
Taylor expanded in z around inf 70.5%
*-commutative70.5%
unpow270.5%
associate-*r*70.5%
associate-*l*90.6%
*-commutative90.6%
associate-*l*95.2%
*-commutative95.2%
Simplified95.2%
expm1-log1p-u92.5%
expm1-udef67.3%
associate-*r*67.3%
*-commutative67.3%
associate-*r*67.3%
Applied egg-rr67.3%
expm1-def95.9%
expm1-log1p98.5%
associate-/r*99.7%
*-commutative99.7%
associate-/r*99.7%
unpow-199.7%
*-commutative99.7%
associate-/r*89.3%
unpow-189.3%
associate-/r*89.3%
Simplified89.3%
Taylor expanded in y around 0 99.7%
associate-*r*95.6%
*-commutative95.6%
associate-/l/95.6%
*-commutative95.6%
Simplified95.6%
Final simplification97.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 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.7%
associate-/r*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
fma-udef99.6%
+-commutative99.6%
associate-/r*99.7%
associate-/r*99.7%
add-sqr-sqrt99.6%
div-inv99.5%
times-frac99.5%
hypot-1-def99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 98.8%
*-commutative98.8%
associate-/r*98.9%
Simplified98.9%
if 1 < (*.f64 z z) Initial program 81.4%
associate-/r*81.3%
+-commutative81.3%
fma-def81.3%
Simplified81.3%
Taylor expanded in z around inf 79.8%
unpow279.8%
Simplified79.8%
Final simplification88.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 0.001) (/ (/ 1.0 x) y) (/ 1.0 (* x (* z (* y z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.001) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (z * (y * z)));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 0.001d0) then
tmp = (1.0d0 / x) / y
else
tmp = 1.0d0 / (x * (z * (y * z)))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.001) {
tmp = (1.0 / x) / y;
} else {
tmp = 1.0 / (x * (z * (y * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 0.001: tmp = (1.0 / x) / y else: tmp = 1.0 / (x * (z * (y * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 0.001) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(x * Float64(z * Float64(y * z)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 0.001)
tmp = (1.0 / x) / y;
else
tmp = 1.0 / (x * (z * (y * z)));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 0.001], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(x * N[(z * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.001:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(y \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e-3Initial program 99.7%
associate-/r*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
fma-udef99.6%
+-commutative99.6%
associate-/r*99.7%
associate-/r*99.7%
add-sqr-sqrt99.6%
div-inv99.5%
times-frac99.5%
hypot-1-def99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 98.8%
*-commutative98.8%
associate-/r*98.9%
Simplified98.9%
if 1e-3 < (*.f64 z z) Initial program 81.4%
associate-/r*81.3%
+-commutative81.3%
fma-def81.3%
Simplified81.3%
Taylor expanded in z around inf 79.8%
unpow279.8%
*-commutative79.8%
associate-*r*86.5%
Simplified86.5%
Final simplification92.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 0.001) (/ (/ 1.0 x) y) (/ 1.0 (* z (* x (* y z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.001) {
tmp = (1.0 / x) / y;
} 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.001d0) then
tmp = (1.0d0 / x) / y
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.001) {
tmp = (1.0 / x) / y;
} 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.001: tmp = (1.0 / x) / y 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.001) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(1.0 / Float64(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.001)
tmp = (1.0 / x) / y;
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.001], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(z * N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.001:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(y \cdot z\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e-3Initial program 99.7%
associate-/r*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
fma-udef99.6%
+-commutative99.6%
associate-/r*99.7%
associate-/r*99.7%
add-sqr-sqrt99.6%
div-inv99.5%
times-frac99.5%
hypot-1-def99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 98.8%
*-commutative98.8%
associate-/r*98.9%
Simplified98.9%
if 1e-3 < (*.f64 z z) Initial program 81.4%
associate-/r*81.3%
+-commutative81.3%
fma-def81.3%
Simplified81.3%
Taylor expanded in z around inf 77.1%
*-commutative77.1%
unpow277.1%
associate-*r*79.3%
associate-*l*91.2%
*-commutative91.2%
associate-*l*93.9%
*-commutative93.9%
Simplified93.9%
Final simplification96.2%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 0.001) (/ (/ 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) <= 0.001) {
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) <= 0.001d0) 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) <= 0.001) {
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) <= 0.001: 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) <= 0.001) tmp = Float64(Float64(1.0 / x) / y); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * 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) <= 0.001)
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], 0.001], N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.001:\\
\;\;\;\;\frac{\frac{1}{x}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\right)}}{z}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e-3Initial program 99.7%
associate-/r*99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
fma-udef99.6%
+-commutative99.6%
associate-/r*99.7%
associate-/r*99.7%
add-sqr-sqrt99.6%
div-inv99.5%
times-frac99.5%
hypot-1-def99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 98.8%
*-commutative98.8%
associate-/r*98.9%
Simplified98.9%
if 1e-3 < (*.f64 z z) Initial program 81.4%
associate-/r*81.3%
+-commutative81.3%
fma-def81.3%
Simplified81.3%
Taylor expanded in z around inf 77.1%
*-commutative77.1%
unpow277.1%
associate-*r*79.3%
associate-*l*91.2%
*-commutative91.2%
associate-*l*93.9%
*-commutative93.9%
Simplified93.9%
expm1-log1p-u87.3%
expm1-udef55.5%
associate-*r*55.5%
*-commutative55.5%
associate-*r*55.5%
Applied egg-rr55.5%
expm1-def88.0%
expm1-log1p94.6%
associate-/r*95.5%
*-commutative95.5%
associate-/r*95.5%
unpow-195.5%
*-commutative95.5%
associate-/r*90.7%
unpow-190.7%
associate-/r*90.6%
Simplified90.6%
Taylor expanded in y around 0 95.5%
Final simplification97.0%
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 89.8%
associate-/r*89.6%
+-commutative89.6%
fma-def89.6%
Simplified89.6%
Taylor expanded in z around 0 52.6%
Final simplification52.6%
(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 2023192
(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)))))