
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) / ((z * z) * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z): return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z) return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) end
function tmp = code(x, y, z) tmp = (x * y) / ((z * z) * (z + 1.0)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) / ((z * z) * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z): return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z) return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) end
function tmp = code(x, y, z) tmp = (x * y) / ((z * z) * (z + 1.0)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (/ (* (/ x_m z) (/ y (+ z 1.0))) z)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
return x_s * (((x_m / z) * (y / (z + 1.0))) / z);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * (((x_m / z) * (y / (z + 1.0d0))) / z)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
return x_s * (((x_m / z) * (y / (z + 1.0))) / z);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): return x_s * (((x_m / z) * (y / (z + 1.0))) / z)
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) return Float64(x_s * Float64(Float64(Float64(x_m / z) * Float64(y / Float64(z + 1.0))) / z)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp = code(x_s, x_m, y, z)
tmp = x_s * (((x_m / z) * (y / (z + 1.0))) / z);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(N[(N[(x$95$m / z), $MachinePrecision] * N[(y / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \frac{\frac{x\_m}{z} \cdot \frac{y}{z + 1}}{z}
\end{array}
Initial program 85.0%
*-commutative85.0%
associate-/l*87.3%
sqr-neg87.3%
associate-/r*87.7%
sqr-neg87.7%
Simplified87.7%
associate-*r/87.6%
*-commutative87.6%
associate-*r/87.6%
associate-/r*93.3%
associate-*l/97.3%
Applied egg-rr97.3%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= z -1.0) (not (<= z 1.0)))
(/ (/ x_m z) (* z (/ z y)))
(/ (/ x_m z) (/ z y)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (x_m / z) / (z * (z / y));
} else {
tmp = (x_m / z) / (z / y);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (x_m / z) / (z * (z / y))
else
tmp = (x_m / z) / (z / y)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (x_m / z) / (z * (z / y));
} else {
tmp = (x_m / z) / (z / y);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = (x_m / z) / (z * (z / y)) else: tmp = (x_m / z) / (z / y) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(Float64(x_m / z) / Float64(z * Float64(z / y))); else tmp = Float64(Float64(x_m / z) / Float64(z / y)); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if ((z <= -1.0) || ~((z <= 1.0)))
tmp = (x_m / z) / (z * (z / y));
else
tmp = (x_m / z) / (z / y);
end
tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x$95$m / z), $MachinePrecision] / N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{\frac{x\_m}{z}}{z \cdot \frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x\_m}{z}}{\frac{z}{y}}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 89.1%
*-commutative89.1%
frac-times93.2%
associate-*l/94.0%
times-frac97.2%
Applied egg-rr97.2%
clear-num97.2%
frac-times95.8%
*-un-lft-identity95.8%
Applied egg-rr95.8%
Taylor expanded in z around inf 94.9%
if -1 < z < 1Initial program 80.6%
*-commutative80.6%
frac-times77.4%
associate-*l/80.6%
times-frac96.8%
Applied egg-rr96.8%
Taylor expanded in z around 0 95.3%
*-commutative95.3%
clear-num95.2%
un-div-inv95.9%
Applied egg-rr95.9%
Final simplification95.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= z -1.0) (not (<= z 1.0)))
(* (/ x_m z) (/ (/ y z) z))
(/ (/ x_m z) (/ z y)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (x_m / z) * ((y / z) / z);
} else {
tmp = (x_m / z) / (z / y);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (x_m / z) * ((y / z) / z)
else
tmp = (x_m / z) / (z / y)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (x_m / z) * ((y / z) / z);
} else {
tmp = (x_m / z) / (z / y);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = (x_m / z) * ((y / z) / z) else: tmp = (x_m / z) / (z / y) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(Float64(x_m / z) * Float64(Float64(y / z) / z)); else tmp = Float64(Float64(x_m / z) / Float64(z / y)); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if ((z <= -1.0) || ~((z <= 1.0)))
tmp = (x_m / z) * ((y / z) / z);
else
tmp = (x_m / z) / (z / y);
end
tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x$95$m / z), $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{x\_m}{z} \cdot \frac{\frac{y}{z}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x\_m}{z}}{\frac{z}{y}}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 89.1%
Taylor expanded in z around inf 88.2%
times-frac93.9%
associate-/r*96.2%
associate-*l/96.8%
associate-/l*95.1%
Applied egg-rr95.1%
if -1 < z < 1Initial program 80.6%
*-commutative80.6%
frac-times77.4%
associate-*l/80.6%
times-frac96.8%
Applied egg-rr96.8%
Taylor expanded in z around 0 95.3%
*-commutative95.3%
clear-num95.2%
un-div-inv95.9%
Applied egg-rr95.9%
Final simplification95.5%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= z -1.0) (not (<= z 1.0)))
(* y (/ (/ x_m (* z z)) z))
(/ (/ x_m z) (/ z y)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = y * ((x_m / (z * z)) / z);
} else {
tmp = (x_m / z) / (z / y);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = y * ((x_m / (z * z)) / z)
else
tmp = (x_m / z) / (z / y)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = y * ((x_m / (z * z)) / z);
} else {
tmp = (x_m / z) / (z / y);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = y * ((x_m / (z * z)) / z) else: tmp = (x_m / z) / (z / y) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(y * Float64(Float64(x_m / Float64(z * z)) / z)); else tmp = Float64(Float64(x_m / z) / Float64(z / y)); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if ((z <= -1.0) || ~((z <= 1.0)))
tmp = y * ((x_m / (z * z)) / z);
else
tmp = (x_m / z) / (z / y);
end
tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(y * N[(N[(x$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;y \cdot \frac{\frac{x\_m}{z \cdot z}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x\_m}{z}}{\frac{z}{y}}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 89.1%
*-commutative89.1%
associate-/l*94.4%
sqr-neg94.4%
associate-/r*95.1%
sqr-neg95.1%
Simplified95.1%
Taylor expanded in z around inf 94.1%
if -1 < z < 1Initial program 80.6%
*-commutative80.6%
frac-times77.4%
associate-*l/80.6%
times-frac96.8%
Applied egg-rr96.8%
Taylor expanded in z around 0 95.3%
*-commutative95.3%
clear-num95.2%
un-div-inv95.9%
Applied egg-rr95.9%
Final simplification95.0%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= z -1.0)
(/ (* (/ x_m z) (/ y z)) z)
(if (<= z 1.0) (/ (/ x_m z) (/ z y)) (* (/ x_m z) (/ (/ y z) z))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = ((x_m / z) * (y / z)) / z;
} else if (z <= 1.0) {
tmp = (x_m / z) / (z / y);
} else {
tmp = (x_m / z) * ((y / z) / z);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.0d0)) then
tmp = ((x_m / z) * (y / z)) / z
else if (z <= 1.0d0) then
tmp = (x_m / z) / (z / y)
else
tmp = (x_m / z) * ((y / z) / z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = ((x_m / z) * (y / z)) / z;
} else if (z <= 1.0) {
tmp = (x_m / z) / (z / y);
} else {
tmp = (x_m / z) * ((y / z) / z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if z <= -1.0: tmp = ((x_m / z) * (y / z)) / z elif z <= 1.0: tmp = (x_m / z) / (z / y) else: tmp = (x_m / z) * ((y / z) / z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(Float64(Float64(x_m / z) * Float64(y / z)) / z); elseif (z <= 1.0) tmp = Float64(Float64(x_m / z) / Float64(z / y)); else tmp = Float64(Float64(x_m / z) * Float64(Float64(y / z) / z)); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (z <= -1.0)
tmp = ((x_m / z) * (y / z)) / z;
elseif (z <= 1.0)
tmp = (x_m / z) / (z / y);
else
tmp = (x_m / z) * ((y / z) / z);
end
tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[z, -1.0], N[(N[(N[(x$95$m / z), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.0], N[(N[(x$95$m / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / z), $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\frac{\frac{x\_m}{z} \cdot \frac{y}{z}}{z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{\frac{x\_m}{z}}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{z} \cdot \frac{\frac{y}{z}}{z}\\
\end{array}
\end{array}
if z < -1Initial program 92.2%
*-commutative92.2%
associate-/l*95.4%
sqr-neg95.4%
associate-/r*95.3%
sqr-neg95.3%
Simplified95.3%
associate-*r/95.4%
*-commutative95.4%
associate-*r/95.3%
associate-/r*98.6%
associate-*l/99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 98.4%
if -1 < z < 1Initial program 80.6%
*-commutative80.6%
frac-times77.4%
associate-*l/80.6%
times-frac96.8%
Applied egg-rr96.8%
Taylor expanded in z around 0 95.3%
*-commutative95.3%
clear-num95.2%
un-div-inv95.9%
Applied egg-rr95.9%
if 1 < z Initial program 86.3%
Taylor expanded in z around inf 85.7%
times-frac93.9%
associate-/r*95.2%
associate-*l/95.2%
associate-/l*93.5%
Applied egg-rr93.5%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y 10000000000.0) (/ (/ y z) (/ z x_m)) (* y (/ (/ x_m z) z)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= 10000000000.0) {
tmp = (y / z) / (z / x_m);
} else {
tmp = y * ((x_m / z) / z);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 10000000000.0d0) then
tmp = (y / z) / (z / x_m)
else
tmp = y * ((x_m / z) / z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= 10000000000.0) {
tmp = (y / z) / (z / x_m);
} else {
tmp = y * ((x_m / z) / z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if y <= 10000000000.0: tmp = (y / z) / (z / x_m) else: tmp = y * ((x_m / z) / z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (y <= 10000000000.0) tmp = Float64(Float64(y / z) / Float64(z / x_m)); else tmp = Float64(y * Float64(Float64(x_m / z) / z)); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (y <= 10000000000.0)
tmp = (y / z) / (z / x_m);
else
tmp = y * ((x_m / z) / z);
end
tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, 10000000000.0], N[(N[(y / z), $MachinePrecision] / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 10000000000:\\
\;\;\;\;\frac{\frac{y}{z}}{\frac{z}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{x\_m}{z}}{z}\\
\end{array}
\end{array}
if y < 1e10Initial program 82.4%
*-commutative82.4%
frac-times84.4%
associate-*l/84.4%
times-frac97.9%
Applied egg-rr97.9%
Taylor expanded in z around 0 75.2%
clear-num75.2%
un-div-inv75.7%
Applied egg-rr75.7%
if 1e10 < y Initial program 90.8%
*-commutative90.8%
associate-/l*94.5%
sqr-neg94.5%
associate-/r*94.5%
sqr-neg94.5%
Simplified94.5%
associate-*r/95.4%
*-commutative95.4%
associate-*r/95.3%
associate-/r*98.4%
associate-*l/99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 76.4%
*-commutative76.4%
associate-/l*83.6%
Applied egg-rr83.6%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y 2e-7) (* (/ x_m z) (/ y z)) (* y (/ (/ x_m z) z)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= 2e-7) {
tmp = (x_m / z) * (y / z);
} else {
tmp = y * ((x_m / z) / z);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2d-7) then
tmp = (x_m / z) * (y / z)
else
tmp = y * ((x_m / z) / z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= 2e-7) {
tmp = (x_m / z) * (y / z);
} else {
tmp = y * ((x_m / z) / z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if y <= 2e-7: tmp = (x_m / z) * (y / z) else: tmp = y * ((x_m / z) / z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (y <= 2e-7) tmp = Float64(Float64(x_m / z) * Float64(y / z)); else tmp = Float64(y * Float64(Float64(x_m / z) / z)); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (y <= 2e-7)
tmp = (x_m / z) * (y / z);
else
tmp = y * ((x_m / z) / z);
end
tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, 2e-7], N[(N[(x$95$m / z), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{x\_m}{z} \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{x\_m}{z}}{z}\\
\end{array}
\end{array}
if y < 1.9999999999999999e-7Initial program 82.0%
*-commutative82.0%
frac-times84.1%
associate-*l/84.0%
times-frac97.9%
Applied egg-rr97.9%
Taylor expanded in z around 0 75.2%
if 1.9999999999999999e-7 < y Initial program 91.2%
*-commutative91.2%
associate-/l*94.8%
sqr-neg94.8%
associate-/r*94.8%
sqr-neg94.8%
Simplified94.8%
associate-*r/95.6%
*-commutative95.6%
associate-*r/95.5%
associate-/r*98.5%
associate-*l/99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 76.5%
*-commutative76.5%
associate-/l*83.3%
Applied egg-rr83.3%
Final simplification77.8%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (* (/ y z) (/ (/ x_m (+ z 1.0)) z))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
return x_s * ((y / z) * ((x_m / (z + 1.0)) / z));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * ((y / z) * ((x_m / (z + 1.0d0)) / z))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
return x_s * ((y / z) * ((x_m / (z + 1.0)) / z));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): return x_s * ((y / z) * ((x_m / (z + 1.0)) / z))
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) return Float64(x_s * Float64(Float64(y / z) * Float64(Float64(x_m / Float64(z + 1.0)) / z))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp = code(x_s, x_m, y, z)
tmp = x_s * ((y / z) * ((x_m / (z + 1.0)) / z));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(N[(y / z), $MachinePrecision] * N[(N[(x$95$m / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \left(\frac{y}{z} \cdot \frac{\frac{x\_m}{z + 1}}{z}\right)
\end{array}
Initial program 85.0%
*-commutative85.0%
frac-times85.4%
associate-*l/87.4%
times-frac97.0%
Applied egg-rr97.0%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (* y (/ (/ x_m z) z))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
return x_s * (y * ((x_m / z) / z));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * (y * ((x_m / z) / z))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
return x_s * (y * ((x_m / z) / z));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): return x_s * (y * ((x_m / z) / z))
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) return Float64(x_s * Float64(y * Float64(Float64(x_m / z) / z))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp = code(x_s, x_m, y, z)
tmp = x_s * (y * ((x_m / z) / z));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(y * N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \left(y \cdot \frac{\frac{x\_m}{z}}{z}\right)
\end{array}
Initial program 85.0%
*-commutative85.0%
associate-/l*87.3%
sqr-neg87.3%
associate-/r*87.7%
sqr-neg87.7%
Simplified87.7%
associate-*r/87.6%
*-commutative87.6%
associate-*r/87.6%
associate-/r*93.3%
associate-*l/97.3%
Applied egg-rr97.3%
Taylor expanded in z around 0 74.2%
*-commutative74.2%
associate-/l*74.9%
Applied egg-rr74.9%
(FPCore (x y z) :precision binary64 (if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z)))
double code(double x, double y, double z) {
double tmp;
if (z < 249.6182814532307) {
tmp = (y * (x / z)) / (z + (z * z));
} else {
tmp = (((y / z) / (1.0 + z)) * x) / z;
}
return tmp;
}
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 < 249.6182814532307d0) then
tmp = (y * (x / z)) / (z + (z * z))
else
tmp = (((y / z) / (1.0d0 + z)) * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < 249.6182814532307) {
tmp = (y * (x / z)) / (z + (z * z));
} else {
tmp = (((y / z) / (1.0 + z)) * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < 249.6182814532307: tmp = (y * (x / z)) / (z + (z * z)) else: tmp = (((y / z) / (1.0 + z)) * x) / z return tmp
function code(x, y, z) tmp = 0.0 if (z < 249.6182814532307) tmp = Float64(Float64(y * Float64(x / z)) / Float64(z + Float64(z * z))); else tmp = Float64(Float64(Float64(Float64(y / z) / Float64(1.0 + z)) * x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < 249.6182814532307) tmp = (y * (x / z)) / (z + (z * z)); else tmp = (((y / z) / (1.0 + z)) * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, 249.6182814532307], N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] / N[(z + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / z), $MachinePrecision] / N[(1.0 + z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z < 249.6182814532307:\\
\;\;\;\;\frac{y \cdot \frac{x}{z}}{z + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{y}{z}}{1 + z} \cdot x}{z}\\
\end{array}
\end{array}
herbie shell --seed 2024157
(FPCore (x y z)
:name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (if (< z 2496182814532307/10000000000000) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1 z)) x) z)))
(/ (* x y) (* (* z z) (+ z 1.0))))