
(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 6 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}
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (/ (* (/ x z) (/ y_m (+ z 1.0))) z)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
return y_s * (((x / z) * (y_m / (z + 1.0))) / z);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (((x / z) * (y_m / (z + 1.0d0))) / z)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (((x / z) * (y_m / (z + 1.0))) / z);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): return y_s * (((x / z) * (y_m / (z + 1.0))) / z)
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) return Float64(y_s * Float64(Float64(Float64(x / z) * Float64(y_m / Float64(z + 1.0))) / z)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp = code(y_s, x, y_m, z)
tmp = y_s * (((x / z) * (y_m / (z + 1.0))) / z);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(N[(N[(x / z), $MachinePrecision] * N[(y$95$m / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \frac{\frac{x}{z} \cdot \frac{y\_m}{z + 1}}{z}
\end{array}
Initial program 82.7%
*-commutative82.7%
associate-/l*86.6%
sqr-neg86.6%
associate-/r*89.9%
sqr-neg89.9%
Simplified89.9%
associate-*r/90.1%
*-commutative90.1%
associate-*r/90.1%
associate-/r*95.0%
associate-*l/99.4%
Applied egg-rr99.4%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* (+ z 1.0) (* z z))))
(*
y_s
(if (<= t_0 -1e+30)
(/ (* (/ x z) (/ y_m z)) z)
(if (<= t_0 5e-111)
(/ (/ x z) (/ z y_m))
(* (/ y_m (* z z)) (/ x (+ z 1.0))))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double t_0 = (z + 1.0) * (z * z);
double tmp;
if (t_0 <= -1e+30) {
tmp = ((x / z) * (y_m / z)) / z;
} else if (t_0 <= 5e-111) {
tmp = (x / z) / (z / y_m);
} else {
tmp = (y_m / (z * z)) * (x / (z + 1.0));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (z + 1.0d0) * (z * z)
if (t_0 <= (-1d+30)) then
tmp = ((x / z) * (y_m / z)) / z
else if (t_0 <= 5d-111) then
tmp = (x / z) / (z / y_m)
else
tmp = (y_m / (z * z)) * (x / (z + 1.0d0))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = (z + 1.0) * (z * z);
double tmp;
if (t_0 <= -1e+30) {
tmp = ((x / z) * (y_m / z)) / z;
} else if (t_0 <= 5e-111) {
tmp = (x / z) / (z / y_m);
} else {
tmp = (y_m / (z * z)) * (x / (z + 1.0));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): t_0 = (z + 1.0) * (z * z) tmp = 0 if t_0 <= -1e+30: tmp = ((x / z) * (y_m / z)) / z elif t_0 <= 5e-111: tmp = (x / z) / (z / y_m) else: tmp = (y_m / (z * z)) * (x / (z + 1.0)) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) t_0 = Float64(Float64(z + 1.0) * Float64(z * z)) tmp = 0.0 if (t_0 <= -1e+30) tmp = Float64(Float64(Float64(x / z) * Float64(y_m / z)) / z); elseif (t_0 <= 5e-111) tmp = Float64(Float64(x / z) / Float64(z / y_m)); else tmp = Float64(Float64(y_m / Float64(z * z)) * Float64(x / Float64(z + 1.0))); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
t_0 = (z + 1.0) * (z * z);
tmp = 0.0;
if (t_0 <= -1e+30)
tmp = ((x / z) * (y_m / z)) / z;
elseif (t_0 <= 5e-111)
tmp = (x / z) / (z / y_m);
else
tmp = (y_m / (z * z)) * (x / (z + 1.0));
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(z + 1.0), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, -1e+30], N[(N[(N[(x / z), $MachinePrecision] * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$0, 5e-111], N[(N[(x / z), $MachinePrecision] / N[(z / y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(x / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
\begin{array}{l}
t_0 := \left(z + 1\right) \cdot \left(z \cdot z\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+30}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot \frac{y\_m}{z}}{z}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-111}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y\_m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y\_m}{z \cdot z} \cdot \frac{x}{z + 1}\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) < -1e30Initial program 79.6%
*-commutative79.6%
associate-/l*88.8%
sqr-neg88.8%
associate-/r*93.9%
sqr-neg93.9%
Simplified93.9%
associate-*r/94.5%
*-commutative94.5%
associate-*r/94.5%
associate-/r*99.7%
associate-*l/99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 99.5%
if -1e30 < (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) < 5.0000000000000003e-111Initial program 83.2%
*-commutative83.2%
associate-/l*82.8%
sqr-neg82.8%
associate-/r*82.8%
sqr-neg82.8%
Simplified82.8%
associate-*r/82.8%
*-commutative82.8%
associate-*r/82.8%
associate-/r*89.2%
associate-*l/98.9%
Applied egg-rr98.9%
Taylor expanded in z around 0 98.9%
*-commutative98.9%
associate-/l*89.2%
Applied egg-rr89.2%
associate-*r/98.9%
associate-*l/98.9%
clear-num98.9%
associate-*l/99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
if 5.0000000000000003e-111 < (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) Initial program 85.0%
*-commutative85.0%
sqr-neg85.0%
times-frac95.2%
sqr-neg95.2%
Simplified95.2%
Final simplification98.1%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (/ (* (/ x z) (/ y_m z)) z)))
(*
y_s
(if (<= z -400000.0)
t_0
(if (<= z 9e-163)
(/ (* (/ x z) y_m) z)
(if (<= z 1.12e+51) (* y_m (/ (/ x (* z z)) (+ z 1.0))) t_0))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double t_0 = ((x / z) * (y_m / z)) / z;
double tmp;
if (z <= -400000.0) {
tmp = t_0;
} else if (z <= 9e-163) {
tmp = ((x / z) * y_m) / z;
} else if (z <= 1.12e+51) {
tmp = y_m * ((x / (z * z)) / (z + 1.0));
} else {
tmp = t_0;
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((x / z) * (y_m / z)) / z
if (z <= (-400000.0d0)) then
tmp = t_0
else if (z <= 9d-163) then
tmp = ((x / z) * y_m) / z
else if (z <= 1.12d+51) then
tmp = y_m * ((x / (z * z)) / (z + 1.0d0))
else
tmp = t_0
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = ((x / z) * (y_m / z)) / z;
double tmp;
if (z <= -400000.0) {
tmp = t_0;
} else if (z <= 9e-163) {
tmp = ((x / z) * y_m) / z;
} else if (z <= 1.12e+51) {
tmp = y_m * ((x / (z * z)) / (z + 1.0));
} else {
tmp = t_0;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): t_0 = ((x / z) * (y_m / z)) / z tmp = 0 if z <= -400000.0: tmp = t_0 elif z <= 9e-163: tmp = ((x / z) * y_m) / z elif z <= 1.12e+51: tmp = y_m * ((x / (z * z)) / (z + 1.0)) else: tmp = t_0 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) t_0 = Float64(Float64(Float64(x / z) * Float64(y_m / z)) / z) tmp = 0.0 if (z <= -400000.0) tmp = t_0; elseif (z <= 9e-163) tmp = Float64(Float64(Float64(x / z) * y_m) / z); elseif (z <= 1.12e+51) tmp = Float64(y_m * Float64(Float64(x / Float64(z * z)) / Float64(z + 1.0))); else tmp = t_0; end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
t_0 = ((x / z) * (y_m / z)) / z;
tmp = 0.0;
if (z <= -400000.0)
tmp = t_0;
elseif (z <= 9e-163)
tmp = ((x / z) * y_m) / z;
elseif (z <= 1.12e+51)
tmp = y_m * ((x / (z * z)) / (z + 1.0));
else
tmp = t_0;
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(N[(x / z), $MachinePrecision] * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, -400000.0], t$95$0, If[LessEqual[z, 9e-163], N[(N[(N[(x / z), $MachinePrecision] * y$95$m), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.12e+51], N[(y$95$m * N[(N[(x / N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{x}{z} \cdot \frac{y\_m}{z}}{z}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -400000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-163}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot y\_m}{z}\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{+51}:\\
\;\;\;\;y\_m \cdot \frac{\frac{x}{z \cdot z}}{z + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if z < -4e5 or 1.11999999999999992e51 < z Initial program 78.8%
*-commutative78.8%
associate-/l*85.8%
sqr-neg85.8%
associate-/r*93.4%
sqr-neg93.4%
Simplified93.4%
associate-*r/93.8%
*-commutative93.8%
associate-*r/93.8%
associate-/r*98.9%
associate-*l/99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 99.7%
if -4e5 < z < 8.9999999999999995e-163Initial program 82.7%
*-commutative82.7%
associate-/l*82.4%
sqr-neg82.4%
associate-/r*82.4%
sqr-neg82.4%
Simplified82.4%
associate-*r/82.4%
*-commutative82.4%
associate-*r/82.4%
associate-/r*89.3%
associate-*l/99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 98.7%
if 8.9999999999999995e-163 < z < 1.11999999999999992e51Initial program 92.7%
*-commutative92.7%
associate-/l*97.6%
sqr-neg97.6%
associate-/r*97.5%
sqr-neg97.5%
Simplified97.5%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (or (<= z -400000.0) (not (<= z 1.0)))
(/ (* (/ x z) (/ y_m z)) z)
(/ (/ x z) (/ z y_m)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z <= -400000.0) || !(z <= 1.0)) {
tmp = ((x / z) * (y_m / z)) / z;
} else {
tmp = (x / z) / (z / y_m);
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-400000.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = ((x / z) * (y_m / z)) / z
else
tmp = (x / z) / (z / y_m)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z <= -400000.0) || !(z <= 1.0)) {
tmp = ((x / z) * (y_m / z)) / z;
} else {
tmp = (x / z) / (z / y_m);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if (z <= -400000.0) or not (z <= 1.0): tmp = ((x / z) * (y_m / z)) / z else: tmp = (x / z) / (z / y_m) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if ((z <= -400000.0) || !(z <= 1.0)) tmp = Float64(Float64(Float64(x / z) * Float64(y_m / z)) / z); else tmp = Float64(Float64(x / z) / Float64(z / y_m)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if ((z <= -400000.0) || ~((z <= 1.0)))
tmp = ((x / z) * (y_m / z)) / z;
else
tmp = (x / z) / (z / y_m);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[Or[LessEqual[z, -400000.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(N[(x / z), $MachinePrecision] * N[(y$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] / N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -400000 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{\frac{x}{z} \cdot \frac{y\_m}{z}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y\_m}}\\
\end{array}
\end{array}
if z < -4e5 or 1 < z Initial program 79.7%
*-commutative79.7%
associate-/l*87.0%
sqr-neg87.0%
associate-/r*93.9%
sqr-neg93.9%
Simplified93.9%
associate-*r/94.2%
*-commutative94.2%
associate-*r/94.2%
associate-/r*98.9%
associate-*l/99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 97.8%
if -4e5 < z < 1Initial program 85.5%
*-commutative85.5%
associate-/l*86.2%
sqr-neg86.2%
associate-/r*86.2%
sqr-neg86.2%
Simplified86.2%
associate-*r/86.2%
*-commutative86.2%
associate-*r/86.1%
associate-/r*91.3%
associate-*l/99.1%
Applied egg-rr99.1%
Taylor expanded in z around 0 97.2%
*-commutative97.2%
associate-/l*89.4%
Applied egg-rr89.4%
associate-*r/97.2%
associate-*l/96.9%
clear-num96.9%
associate-*l/97.3%
*-un-lft-identity97.3%
Applied egg-rr97.3%
Final simplification97.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (or (<= z -400000.0) (not (<= z 1.0)))
(* (/ x z) (/ y_m (* z z)))
(/ (/ x z) (/ z y_m)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z <= -400000.0) || !(z <= 1.0)) {
tmp = (x / z) * (y_m / (z * z));
} else {
tmp = (x / z) / (z / y_m);
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-400000.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (x / z) * (y_m / (z * z))
else
tmp = (x / z) / (z / y_m)
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z <= -400000.0) || !(z <= 1.0)) {
tmp = (x / z) * (y_m / (z * z));
} else {
tmp = (x / z) / (z / y_m);
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if (z <= -400000.0) or not (z <= 1.0): tmp = (x / z) * (y_m / (z * z)) else: tmp = (x / z) / (z / y_m) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if ((z <= -400000.0) || !(z <= 1.0)) tmp = Float64(Float64(x / z) * Float64(y_m / Float64(z * z))); else tmp = Float64(Float64(x / z) / Float64(z / y_m)); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if ((z <= -400000.0) || ~((z <= 1.0)))
tmp = (x / z) * (y_m / (z * z));
else
tmp = (x / z) / (z / y_m);
end
tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[Or[LessEqual[z, -400000.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * N[(y$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] / N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -400000 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{x}{z} \cdot \frac{y\_m}{z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y\_m}}\\
\end{array}
\end{array}
if z < -4e5 or 1 < z Initial program 79.7%
*-commutative79.7%
sqr-neg79.7%
times-frac94.7%
sqr-neg94.7%
Simplified94.7%
Taylor expanded in z around inf 92.8%
if -4e5 < z < 1Initial program 85.5%
*-commutative85.5%
associate-/l*86.2%
sqr-neg86.2%
associate-/r*86.2%
sqr-neg86.2%
Simplified86.2%
associate-*r/86.2%
*-commutative86.2%
associate-*r/86.1%
associate-/r*91.3%
associate-*l/99.1%
Applied egg-rr99.1%
Taylor expanded in z around 0 97.2%
*-commutative97.2%
associate-/l*89.4%
Applied egg-rr89.4%
associate-*r/97.2%
associate-*l/96.9%
clear-num96.9%
associate-*l/97.3%
*-un-lft-identity97.3%
Applied egg-rr97.3%
Final simplification95.1%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (* y_m (/ (/ x z) z))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m * ((x / z) / z));
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (y_m * ((x / z) / z))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m * ((x / z) / z));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): return y_s * (y_m * ((x / z) / z))
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) return Float64(y_s * Float64(y_m * Float64(Float64(x / z) / z))) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp = code(y_s, x, y_m, z)
tmp = y_s * (y_m * ((x / z) / z));
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(y$95$m * N[(N[(x / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \left(y\_m \cdot \frac{\frac{x}{z}}{z}\right)
\end{array}
Initial program 82.7%
*-commutative82.7%
associate-/l*86.6%
sqr-neg86.6%
associate-/r*89.9%
sqr-neg89.9%
Simplified89.9%
associate-*r/90.1%
*-commutative90.1%
associate-*r/90.1%
associate-/r*95.0%
associate-*l/99.4%
Applied egg-rr99.4%
Taylor expanded in z around 0 74.3%
*-commutative74.3%
associate-/l*75.2%
Applied egg-rr75.2%
(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 2024087
(FPCore (x y z)
:name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
:precision binary64
:alt
(if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z))
(/ (* x y) (* (* z z) (+ z 1.0))))