
(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 8 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 (<= (/ 1.0 x) -1e+27) (* (/ (/ 1.0 x) (hypot 1.0 z)) (/ (/ 1.0 y) (hypot 1.0 z))) (* (/ 1.0 (hypot 1.0 z)) (/ (/ 1.0 (* x y)) (hypot 1.0 z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((1.0 / x) <= -1e+27) {
tmp = ((1.0 / x) / hypot(1.0, z)) * ((1.0 / y) / hypot(1.0, z));
} else {
tmp = (1.0 / hypot(1.0, z)) * ((1.0 / (x * y)) / hypot(1.0, z));
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if ((1.0 / x) <= -1e+27) {
tmp = ((1.0 / x) / Math.hypot(1.0, z)) * ((1.0 / y) / Math.hypot(1.0, z));
} else {
tmp = (1.0 / Math.hypot(1.0, z)) * ((1.0 / (x * y)) / Math.hypot(1.0, z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (1.0 / x) <= -1e+27: tmp = ((1.0 / x) / math.hypot(1.0, z)) * ((1.0 / y) / math.hypot(1.0, z)) else: tmp = (1.0 / math.hypot(1.0, z)) * ((1.0 / (x * y)) / math.hypot(1.0, z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(1.0 / x) <= -1e+27) tmp = Float64(Float64(Float64(1.0 / x) / hypot(1.0, z)) * Float64(Float64(1.0 / y) / hypot(1.0, z))); else tmp = Float64(Float64(1.0 / hypot(1.0, z)) * Float64(Float64(1.0 / Float64(x * y)) / hypot(1.0, z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((1.0 / x) <= -1e+27)
tmp = ((1.0 / x) / hypot(1.0, z)) * ((1.0 / y) / hypot(1.0, z));
else
tmp = (1.0 / hypot(1.0, z)) * ((1.0 / (x * y)) / hypot(1.0, 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[(1.0 / x), $MachinePrecision], -1e+27], N[(N[(N[(1.0 / x), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / y), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[(x * y), $MachinePrecision]), $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}\;\frac{1}{x} \leq -1 \cdot 10^{+27}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{y}}{\mathsf{hypot}\left(1, z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{x \cdot y}}{\mathsf{hypot}\left(1, z\right)}\\
\end{array}
\end{array}
if (/.f64 1 x) < -1e27Initial program 82.2%
associate-/r*82.3%
+-commutative82.3%
fma-def82.3%
Simplified82.3%
fma-udef82.3%
+-commutative82.3%
associate-/r*82.2%
associate-/r*75.5%
div-inv75.4%
add-sqr-sqrt75.4%
times-frac84.8%
hypot-1-def84.8%
hypot-1-def99.0%
Applied egg-rr99.0%
if -1e27 < (/.f64 1 x) Initial program 93.8%
associate-/r*93.8%
+-commutative93.8%
fma-def93.8%
Simplified93.8%
fma-udef93.8%
+-commutative93.8%
associate-/r*93.8%
associate-/r*93.3%
add-sqr-sqrt93.3%
*-un-lft-identity93.3%
times-frac93.3%
hypot-1-def93.3%
associate-/l/93.2%
hypot-1-def96.6%
Applied egg-rr96.6%
Final simplification97.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+201) (/ 1.0 (* x (+ y (* y (* z z))))) (/ (/ 1.0 z) (* x (* z y)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+201) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = (1.0 / z) / (x * (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) <= 5d+201) then
tmp = 1.0d0 / (x * (y + (y * (z * z))))
else
tmp = (1.0d0 / z) / (x * (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) <= 5e+201) {
tmp = 1.0 / (x * (y + (y * (z * z))));
} else {
tmp = (1.0 / z) / (x * (z * y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 5e+201: tmp = 1.0 / (x * (y + (y * (z * z)))) else: tmp = (1.0 / z) / (x * (z * y)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+201) tmp = Float64(1.0 / Float64(x * Float64(y + Float64(y * Float64(z * z))))); else tmp = Float64(Float64(1.0 / z) / Float64(x * 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) <= 5e+201)
tmp = 1.0 / (x * (y + (y * (z * z))));
else
tmp = (1.0 / z) / (x * (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], 5e+201], 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[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+201}:\\
\;\;\;\;\frac{1}{x \cdot \left(y + y \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) < 4.9999999999999995e201Initial program 98.0%
associate-/r*98.0%
+-commutative98.0%
fma-def98.0%
Simplified98.0%
fma-udef98.0%
distribute-lft-in98.0%
*-rgt-identity98.0%
Applied egg-rr98.0%
if 4.9999999999999995e201 < (*.f64 z z) Initial program 75.6%
associate-/r*75.5%
+-commutative75.5%
fma-def75.5%
Simplified75.5%
Taylor expanded in z around inf 74.3%
unpow274.3%
*-commutative74.3%
associate-*l*75.1%
*-commutative75.1%
associate-*l*92.4%
Simplified92.4%
add-cube-cbrt91.9%
pow391.9%
associate-/r*92.8%
*-commutative92.8%
*-commutative92.8%
associate-*l*96.2%
Applied egg-rr96.2%
rem-cube-cbrt96.5%
*-commutative96.5%
Applied egg-rr96.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 (<= z 1.0)
(/ 1.0 (* x y))
(if (<= z 1.75e+192)
(/ 1.0 (* x (* z (* z y))))
(/ 1.0 (* z (* y (* x z)))))))assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
tmp = 1.0 / (x * y);
} else if (z <= 1.75e+192) {
tmp = 1.0 / (x * (z * (z * y)));
} else {
tmp = 1.0 / (z * (y * (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 <= 1.0d0) then
tmp = 1.0d0 / (x * y)
else if (z <= 1.75d+192) then
tmp = 1.0d0 / (x * (z * (z * y)))
else
tmp = 1.0d0 / (z * (y * (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 <= 1.0) {
tmp = 1.0 / (x * y);
} else if (z <= 1.75e+192) {
tmp = 1.0 / (x * (z * (z * y)));
} else {
tmp = 1.0 / (z * (y * (x * z)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if z <= 1.0: tmp = 1.0 / (x * y) elif z <= 1.75e+192: tmp = 1.0 / (x * (z * (z * y))) else: tmp = 1.0 / (z * (y * (x * z))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (z <= 1.0) tmp = Float64(1.0 / Float64(x * y)); elseif (z <= 1.75e+192) tmp = Float64(1.0 / Float64(x * Float64(z * Float64(z * y)))); else tmp = Float64(1.0 / Float64(z * Float64(y * 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 <= 1.0)
tmp = 1.0 / (x * y);
elseif (z <= 1.75e+192)
tmp = 1.0 / (x * (z * (z * y)));
else
tmp = 1.0 / (z * (y * (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[z, 1.0], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.75e+192], N[(1.0 / N[(x * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z * N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{+192}:\\
\;\;\;\;\frac{1}{x \cdot \left(z \cdot \left(z \cdot y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(y \cdot \left(x \cdot z\right)\right)}\\
\end{array}
\end{array}
if z < 1Initial program 94.4%
associate-/r*94.5%
+-commutative94.5%
fma-def94.5%
Simplified94.5%
Taylor expanded in z around 0 71.1%
if 1 < z < 1.74999999999999991e192Initial program 86.0%
associate-/r*85.7%
+-commutative85.7%
fma-def85.7%
Simplified85.7%
Taylor expanded in z around inf 85.7%
unpow285.7%
*-commutative85.7%
associate-*r*92.6%
Simplified92.6%
if 1.74999999999999991e192 < z Initial program 70.6%
associate-/r*70.6%
+-commutative70.6%
fma-def70.6%
Simplified70.6%
Taylor expanded in z around inf 70.6%
unpow270.6%
*-commutative70.6%
associate-*l*70.1%
*-commutative70.1%
associate-*l*85.1%
Simplified85.1%
Taylor expanded in z around 0 99.9%
Final simplification77.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e-7) (/ 1.0 (* x y)) (/ 1.0 (* (* z y) (* x z)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e-7) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / ((z * y) * (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) <= 1d-7) then
tmp = 1.0d0 / (x * y)
else
tmp = 1.0d0 / ((z * y) * (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) <= 1e-7) {
tmp = 1.0 / (x * y);
} else {
tmp = 1.0 / ((z * y) * (x * z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 1e-7: tmp = 1.0 / (x * y) else: tmp = 1.0 / ((z * y) * (x * z)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e-7) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(1.0 / Float64(Float64(z * y) * 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) <= 1e-7)
tmp = 1.0 / (x * y);
else
tmp = 1.0 / ((z * y) * (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], 1e-7], N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(z * y), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{-7}:\\
\;\;\;\;\frac{1}{x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(z \cdot y\right) \cdot \left(x \cdot z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 9.9999999999999995e-8Initial program 99.7%
associate-/r*99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around 0 98.9%
if 9.9999999999999995e-8 < (*.f64 z z) Initial program 82.2%
associate-/r*82.1%
+-commutative82.1%
fma-def82.1%
Simplified82.1%
Taylor expanded in z around inf 82.4%
unpow282.4%
*-commutative82.4%
associate-*l*78.5%
*-commutative78.5%
associate-*l*89.5%
Simplified89.5%
expm1-log1p-u54.9%
expm1-udef46.5%
*-commutative46.5%
*-commutative46.5%
associate-*l*46.2%
Applied egg-rr46.2%
expm1-def59.1%
expm1-log1p93.8%
associate-*r*93.9%
Simplified93.9%
Final simplification96.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1e-7) (/ 1.0 (* x y)) (/ (/ 1.0 z) (* x (* z y)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e-7) {
tmp = 1.0 / (x * y);
} else {
tmp = (1.0 / z) / (x * (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) <= 1d-7) then
tmp = 1.0d0 / (x * y)
else
tmp = (1.0d0 / z) / (x * (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) <= 1e-7) {
tmp = 1.0 / (x * y);
} else {
tmp = (1.0 / z) / (x * (z * y));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 1e-7: tmp = 1.0 / (x * y) else: tmp = (1.0 / z) / (x * (z * y)) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e-7) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(Float64(1.0 / z) / Float64(x * 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) <= 1e-7)
tmp = 1.0 / (x * y);
else
tmp = (1.0 / z) / (x * (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], 1e-7], 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}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{-7}:\\
\;\;\;\;\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) < 9.9999999999999995e-8Initial program 99.7%
associate-/r*99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around 0 98.9%
if 9.9999999999999995e-8 < (*.f64 z z) Initial program 82.2%
associate-/r*82.1%
+-commutative82.1%
fma-def82.1%
Simplified82.1%
Taylor expanded in z around inf 82.4%
unpow282.4%
*-commutative82.4%
associate-*l*78.5%
*-commutative78.5%
associate-*l*89.5%
Simplified89.5%
add-cube-cbrt88.9%
pow388.9%
associate-/r*89.4%
*-commutative89.4%
*-commutative89.4%
associate-*l*93.8%
Applied egg-rr93.8%
rem-cube-cbrt94.3%
*-commutative94.3%
Applied egg-rr94.3%
Final simplification96.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 1.0) (/ 1.0 (* x y)) (/ 1.0 (* x (* y (* z z))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (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 <= 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 <= 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 <= 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 (z <= 1.0) tmp = Float64(1.0 / Float64(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 <= 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[z, 1.0], 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}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\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 < 1Initial program 94.4%
associate-/r*94.5%
+-commutative94.5%
fma-def94.5%
Simplified94.5%
Taylor expanded in z around 0 71.1%
if 1 < z Initial program 80.0%
associate-/r*79.8%
+-commutative79.8%
fma-def79.8%
Simplified79.8%
Taylor expanded in z around inf 79.8%
unpow279.8%
Simplified79.8%
Final simplification73.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= z 1.0) (/ 1.0 (* x y)) (/ 1.0 (* x (* z (* z y))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (z <= 1.0) {
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 <= 1.0d0) 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 <= 1.0) {
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 <= 1.0: 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 (z <= 1.0) tmp = Float64(1.0 / Float64(x * y)); else tmp = Float64(1.0 / Float64(x * Float64(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 <= 1.0)
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[z, 1.0], 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}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\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 z < 1Initial program 94.4%
associate-/r*94.5%
+-commutative94.5%
fma-def94.5%
Simplified94.5%
Taylor expanded in z around 0 71.1%
if 1 < z Initial program 80.0%
associate-/r*79.8%
+-commutative79.8%
fma-def79.8%
Simplified79.8%
Taylor expanded in z around inf 79.8%
unpow279.8%
*-commutative79.8%
associate-*r*86.9%
Simplified86.9%
Final simplification75.2%
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 90.7%
associate-/r*90.6%
+-commutative90.6%
fma-def90.6%
Simplified90.6%
Taylor expanded in z around 0 57.0%
Final simplification57.0%
(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 2023257
(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)))))