
(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 (<= (* z z) 4e+41) (/ (/ (/ 1.0 y) x) (fma z z 1.0)) (/ (/ 1.0 z) (* x (* z y)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+41) {
tmp = ((1.0 / y) / x) / fma(z, z, 1.0);
} 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) <= 4e+41) tmp = Float64(Float64(Float64(1.0 / y) / x) / fma(z, z, 1.0)); else tmp = Float64(Float64(1.0 / z) / Float64(x * 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], 4e+41], N[(N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+41}:\\
\;\;\;\;\frac{\frac{\frac{1}{y}}{x}}{\mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.00000000000000002e41Initial program 99.6%
associate-/r*99.6%
associate-/r*98.6%
sqr-neg98.6%
+-commutative98.6%
sqr-neg98.6%
fma-def98.6%
Simplified98.6%
add-log-exp26.8%
*-un-lft-identity26.8%
log-prod26.8%
metadata-eval26.8%
add-log-exp98.6%
*-commutative98.6%
associate-/r*99.7%
Applied egg-rr99.7%
if 4.00000000000000002e41 < (*.f64 z z) Initial program 80.5%
associate-/r*80.4%
*-commutative80.4%
sqr-neg80.4%
+-commutative80.4%
distribute-lft1-in80.4%
*-commutative80.4%
fma-def80.4%
sqr-neg80.4%
Simplified80.4%
Taylor expanded in z around inf 80.4%
unpow280.4%
associate-*r*81.0%
*-commutative81.0%
Simplified81.0%
associate-/r*80.1%
associate-/r*80.2%
div-inv80.1%
times-frac95.2%
Applied egg-rr95.2%
frac-times80.1%
div-inv80.2%
associate-/l/80.1%
associate-/l/81.0%
associate-*r*91.7%
associate-*l*95.1%
associate-/r*95.1%
*-commutative95.1%
associate-*l*97.0%
*-commutative97.0%
Applied egg-rr97.0%
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) 0.004)
(/ (/ 1.0 y) x)
(if (<= (* z z) 5e+293)
(/ 1.0 (* x (* (* z z) y)))
(/ 1.0 (* y (* z (* z x)))))))assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.004) {
tmp = (1.0 / y) / x;
} else if ((z * z) <= 5e+293) {
tmp = 1.0 / (x * ((z * z) * y));
} else {
tmp = 1.0 / (y * (z * (z * x)));
}
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.004d0) then
tmp = (1.0d0 / y) / x
else if ((z * z) <= 5d+293) then
tmp = 1.0d0 / (x * ((z * z) * y))
else
tmp = 1.0d0 / (y * (z * (z * x)))
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.004) {
tmp = (1.0 / y) / x;
} else if ((z * z) <= 5e+293) {
tmp = 1.0 / (x * ((z * z) * y));
} else {
tmp = 1.0 / (y * (z * (z * x)));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if (z * z) <= 0.004: tmp = (1.0 / y) / x elif (z * z) <= 5e+293: tmp = 1.0 / (x * ((z * z) * y)) else: tmp = 1.0 / (y * (z * (z * x))) return tmp
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 0.004) tmp = Float64(Float64(1.0 / y) / x); elseif (Float64(z * z) <= 5e+293) tmp = Float64(1.0 / Float64(x * Float64(Float64(z * z) * y))); else tmp = Float64(1.0 / Float64(y * Float64(z * Float64(z * x)))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if ((z * z) <= 0.004)
tmp = (1.0 / y) / x;
elseif ((z * z) <= 5e+293)
tmp = 1.0 / (x * ((z * z) * y));
else
tmp = 1.0 / (y * (z * (z * x)));
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.004], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 5e+293], N[(1.0 / N[(x * N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(y * N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.004:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+293}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(z \cdot z\right) \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.0040000000000000001Initial program 99.6%
associate-/r*98.5%
*-commutative98.5%
sqr-neg98.5%
+-commutative98.5%
distribute-lft1-in98.5%
*-commutative98.5%
fma-def98.5%
sqr-neg98.5%
Simplified98.5%
Taylor expanded in z around 0 97.3%
*-commutative97.3%
Simplified97.3%
associate-/r*98.5%
div-inv98.4%
Applied egg-rr98.4%
div-inv98.5%
Applied egg-rr98.5%
if 0.0040000000000000001 < (*.f64 z z) < 5.00000000000000033e293Initial program 96.5%
associate-/r*95.9%
*-commutative95.9%
sqr-neg95.9%
+-commutative95.9%
distribute-lft1-in95.9%
*-commutative95.9%
fma-def95.9%
sqr-neg95.9%
Simplified95.9%
Taylor expanded in z around inf 92.9%
unpow292.9%
Simplified92.9%
if 5.00000000000000033e293 < (*.f64 z z) Initial program 68.6%
associate-/r*68.6%
*-commutative68.6%
sqr-neg68.6%
+-commutative68.6%
distribute-lft1-in68.6%
*-commutative68.6%
fma-def68.6%
sqr-neg68.6%
Simplified68.6%
Taylor expanded in z around inf 68.6%
*-commutative68.6%
unpow268.6%
associate-*l*68.6%
associate-*l*88.3%
Simplified88.3%
Final simplification94.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 1000000.0) (/ 1.0 (* x (+ y (* (* z z) y)))) (/ (/ 1.0 z) (* x (* z y)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1000000.0) {
tmp = 1.0 / (x * (y + ((z * z) * 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) <= 1000000.0d0) then
tmp = 1.0d0 / (x * (y + ((z * z) * 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) <= 1000000.0) {
tmp = 1.0 / (x * (y + ((z * z) * 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) <= 1000000.0: tmp = 1.0 / (x * (y + ((z * z) * 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) <= 1000000.0) tmp = Float64(1.0 / Float64(x * Float64(y + Float64(Float64(z * z) * 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) <= 1000000.0)
tmp = 1.0 / (x * (y + ((z * z) * 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], 1000000.0], N[(1.0 / N[(x * N[(y + N[(N[(z * z), $MachinePrecision] * y), $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 1000000:\\
\;\;\;\;\frac{1}{x \cdot \left(y + \left(z \cdot z\right) \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e6Initial program 99.6%
associate-/r*98.6%
*-commutative98.6%
sqr-neg98.6%
+-commutative98.6%
distribute-lft1-in98.6%
*-commutative98.6%
fma-def98.6%
sqr-neg98.6%
Simplified98.6%
fma-udef98.6%
Applied egg-rr98.6%
if 1e6 < (*.f64 z z) Initial program 82.3%
associate-/r*82.0%
*-commutative82.0%
sqr-neg82.0%
+-commutative82.0%
distribute-lft1-in82.0%
*-commutative82.0%
fma-def82.0%
sqr-neg82.0%
Simplified82.0%
Taylor expanded in z around inf 82.0%
unpow282.0%
associate-*r*82.6%
*-commutative82.6%
Simplified82.6%
associate-/r*82.0%
associate-/r*82.1%
div-inv82.0%
times-frac95.6%
Applied egg-rr95.6%
frac-times82.0%
div-inv82.1%
associate-/l/82.0%
associate-/l/82.6%
associate-*r*92.2%
associate-*l*95.3%
associate-/r*95.6%
*-commutative95.6%
associate-*l*97.3%
*-commutative97.3%
Applied egg-rr97.3%
Final simplification98.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e+35) (/ (/ 1.0 x) (* y (+ (* z z) 1.0))) (/ (/ 1.0 z) (* x (* z y)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+35) {
tmp = (1.0 / x) / (y * ((z * z) + 1.0));
} 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+35) then
tmp = (1.0d0 / x) / (y * ((z * z) + 1.0d0))
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+35) {
tmp = (1.0 / x) / (y * ((z * z) + 1.0));
} 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+35: tmp = (1.0 / x) / (y * ((z * z) + 1.0)) 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+35) tmp = Float64(Float64(1.0 / x) / Float64(y * Float64(Float64(z * z) + 1.0))); 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+35)
tmp = (1.0 / x) / (y * ((z * z) + 1.0));
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+35], N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(N[(z * z), $MachinePrecision] + 1.0), $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^{+35}:\\
\;\;\;\;\frac{\frac{1}{x}}{y \cdot \left(z \cdot z + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000021e35Initial program 99.6%
if 5.00000000000000021e35 < (*.f64 z z) Initial program 81.2%
associate-/r*81.1%
*-commutative81.1%
sqr-neg81.1%
+-commutative81.1%
distribute-lft1-in81.1%
*-commutative81.1%
fma-def81.1%
sqr-neg81.1%
Simplified81.1%
Taylor expanded in z around inf 81.1%
unpow281.1%
associate-*r*81.7%
*-commutative81.7%
Simplified81.7%
associate-/r*80.9%
associate-/r*80.9%
div-inv80.9%
times-frac95.3%
Applied egg-rr95.3%
frac-times80.9%
div-inv80.9%
associate-/l/80.9%
associate-/l/81.7%
associate-*r*92.0%
associate-*l*95.3%
associate-/r*95.3%
*-commutative95.3%
associate-*l*97.1%
*-commutative97.1%
Applied egg-rr97.1%
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) 0.004) (/ (/ 1.0 y) x) (/ 1.0 (* z (* x (* z y))))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.004) {
tmp = (1.0 / y) / x;
} 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) <= 0.004d0) then
tmp = (1.0d0 / y) / x
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) <= 0.004) {
tmp = (1.0 / y) / x;
} 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) <= 0.004: tmp = (1.0 / y) / x 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) <= 0.004) tmp = Float64(Float64(1.0 / y) / x); else tmp = Float64(1.0 / Float64(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) <= 0.004)
tmp = (1.0 / y) / x;
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], 0.004], N[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(z * N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.004:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(x \cdot \left(z \cdot y\right)\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.0040000000000000001Initial program 99.6%
associate-/r*98.5%
*-commutative98.5%
sqr-neg98.5%
+-commutative98.5%
distribute-lft1-in98.5%
*-commutative98.5%
fma-def98.5%
sqr-neg98.5%
Simplified98.5%
Taylor expanded in z around 0 97.3%
*-commutative97.3%
Simplified97.3%
associate-/r*98.5%
div-inv98.4%
Applied egg-rr98.4%
div-inv98.5%
Applied egg-rr98.5%
if 0.0040000000000000001 < (*.f64 z z) Initial program 82.8%
associate-/r*82.4%
*-commutative82.4%
sqr-neg82.4%
+-commutative82.4%
distribute-lft1-in82.4%
*-commutative82.4%
fma-def82.4%
sqr-neg82.4%
Simplified82.4%
Taylor expanded in z around inf 80.9%
unpow280.9%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
associate-/r*80.9%
associate-/r*81.0%
*-un-lft-identity81.0%
times-frac90.0%
associate-/l/90.0%
Applied egg-rr90.0%
clear-num90.0%
frac-times89.5%
metadata-eval89.5%
associate-/r/90.9%
/-rgt-identity90.9%
associate-*r*93.9%
Applied egg-rr93.9%
Taylor expanded in z around 0 95.4%
Final simplification97.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.004) (/ (/ 1.0 y) x) (/ (/ 1.0 z) (* x (* z y)))))
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 0.004) {
tmp = (1.0 / y) / x;
} 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) <= 0.004d0) then
tmp = (1.0d0 / y) / x
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) <= 0.004) {
tmp = (1.0 / y) / x;
} 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) <= 0.004: tmp = (1.0 / y) / x 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) <= 0.004) tmp = Float64(Float64(1.0 / y) / x); 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) <= 0.004)
tmp = (1.0 / y) / x;
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], 0.004], N[(N[(1.0 / y), $MachinePrecision] / x), $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 0.004:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.0040000000000000001Initial program 99.6%
associate-/r*98.5%
*-commutative98.5%
sqr-neg98.5%
+-commutative98.5%
distribute-lft1-in98.5%
*-commutative98.5%
fma-def98.5%
sqr-neg98.5%
Simplified98.5%
Taylor expanded in z around 0 97.3%
*-commutative97.3%
Simplified97.3%
associate-/r*98.5%
div-inv98.4%
Applied egg-rr98.4%
div-inv98.5%
Applied egg-rr98.5%
if 0.0040000000000000001 < (*.f64 z z) Initial program 82.8%
associate-/r*82.4%
*-commutative82.4%
sqr-neg82.4%
+-commutative82.4%
distribute-lft1-in82.4%
*-commutative82.4%
fma-def82.4%
sqr-neg82.4%
Simplified82.4%
Taylor expanded in z around inf 80.9%
unpow280.9%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
associate-/r*80.9%
associate-/r*81.0%
div-inv81.0%
times-frac94.2%
Applied egg-rr94.2%
frac-times81.0%
div-inv81.0%
associate-/l/80.9%
associate-/l/81.5%
associate-*r*90.9%
associate-*l*93.9%
associate-/r*94.1%
*-commutative94.1%
associate-*l*95.8%
*-commutative95.8%
Applied egg-rr95.8%
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 1.0) (/ (/ 1.0 y) x) (/ 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 / y) / x;
} 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 / y) / x
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 / y) / x;
} 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 / y) / x 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(Float64(1.0 / y) / x); else tmp = Float64(1.0 / Float64(x * Float64(Float64(z * 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 / y) / x;
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[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(x * N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(z \cdot z\right) \cdot y\right)}\\
\end{array}
\end{array}
if z < 1Initial program 94.9%
associate-/r*94.0%
*-commutative94.0%
sqr-neg94.0%
+-commutative94.0%
distribute-lft1-in94.0%
*-commutative94.0%
fma-def94.0%
sqr-neg94.0%
Simplified94.0%
Taylor expanded in z around 0 73.1%
*-commutative73.1%
Simplified73.1%
associate-/r*73.8%
div-inv73.7%
Applied egg-rr73.7%
div-inv73.8%
Applied egg-rr73.8%
if 1 < z Initial program 81.2%
associate-/r*81.2%
*-commutative81.2%
sqr-neg81.2%
+-commutative81.2%
distribute-lft1-in81.2%
*-commutative81.2%
fma-def81.2%
sqr-neg81.2%
Simplified81.2%
Taylor expanded in z around inf 78.1%
unpow278.1%
Simplified78.1%
Final simplification74.7%
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.8%
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 61.0%
*-commutative61.0%
Simplified61.0%
Final simplification61.0%
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(Float64(1.0 / 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[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{x}}{y}
\end{array}
Initial program 91.8%
distribute-lft-in91.9%
*-rgt-identity91.9%
+-commutative91.9%
associate-*r*97.0%
fma-def97.0%
Applied egg-rr97.0%
Taylor expanded in z around 0 61.0%
associate-/r*61.2%
Simplified61.2%
Final simplification61.2%
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(Float64(1.0 / 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[(N[(1.0 / y), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{1}{y}}{x}
\end{array}
Initial program 91.8%
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 61.0%
*-commutative61.0%
Simplified61.0%
associate-/r*61.3%
div-inv61.2%
Applied egg-rr61.2%
div-inv61.3%
Applied egg-rr61.3%
Final simplification61.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 2023275
(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)))))