
(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 15 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
(if (<= (* (* z z) (+ z 1.0)) -1e+191)
(/ (* (/ (/ y z) z) x_m) z)
(/ (* (/ x_m z) y) (fma z 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 * z) * (z + 1.0)) <= -1e+191) {
tmp = (((y / z) / z) * x_m) / z;
} else {
tmp = ((x_m / z) * y) / fma(z, 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 (Float64(Float64(z * z) * Float64(z + 1.0)) <= -1e+191) tmp = Float64(Float64(Float64(Float64(y / z) / z) * x_m) / z); else tmp = Float64(Float64(Float64(x_m / z) * y) / fma(z, z, z)); end return Float64(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[N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], -1e+191], N[(N[(N[(N[(y / z), $MachinePrecision] / z), $MachinePrecision] * x$95$m), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(x$95$m / z), $MachinePrecision] * y), $MachinePrecision] / N[(z * z + 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}\;\left(z \cdot z\right) \cdot \left(z + 1\right) \leq -1 \cdot 10^{+191}:\\
\;\;\;\;\frac{\frac{\frac{y}{z}}{z} \cdot x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x\_m}{z} \cdot y}{\mathsf{fma}\left(z, z, z\right)}\\
\end{array}
\end{array}
if (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) < -1.00000000000000007e191Initial program 82.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6498.2
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.2
Applied rewrites98.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
lift-fma.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
clear-numN/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
associate-/r/N/A
lift-fma.f64N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
Applied rewrites92.8%
Taylor expanded in z around inf
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.3
Applied rewrites99.3%
if -1.00000000000000007e191 < (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) Initial program 87.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/r*N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6497.4
Applied rewrites97.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 (<= (/ (* x_m y) (* (* z z) (+ z 1.0))) 1e-42)
(/ x_m (* (/ (fma z z z) y) z))
(* (/ (/ x_m (fma z z 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 (((x_m * y) / ((z * z) * (z + 1.0))) <= 1e-42) {
tmp = x_m / ((fma(z, z, z) / y) * z);
} else {
tmp = ((x_m / fma(z, z, 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 (Float64(Float64(x_m * y) / Float64(Float64(z * z) * Float64(z + 1.0))) <= 1e-42) tmp = Float64(x_m / Float64(Float64(fma(z, z, z) / y) * z)); else tmp = Float64(Float64(Float64(x_m / fma(z, z, z)) / z) * y); end return Float64(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[N[(N[(x$95$m * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-42], N[(x$95$m / N[(N[(N[(z * z + z), $MachinePrecision] / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$95$m / N[(z * z + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * y), $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}\;\frac{x\_m \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \leq 10^{-42}:\\
\;\;\;\;\frac{x\_m}{\frac{\mathsf{fma}\left(z, z, z\right)}{y} \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x\_m}{\mathsf{fma}\left(z, z, z\right)}}{z} \cdot y\\
\end{array}
\end{array}
if (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) < 1.00000000000000004e-42Initial program 91.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6494.8
Applied rewrites94.8%
if 1.00000000000000004e-42 < (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) Initial program 74.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6484.5
Applied rewrites84.5%
Final simplification91.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 (<= (/ (* x_m y) (* (* z z) (+ z 1.0))) 5e+109)
(* (/ y (* (fma z z z) z)) x_m)
(/ y (* (/ z x_m) 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 (((x_m * y) / ((z * z) * (z + 1.0))) <= 5e+109) {
tmp = (y / (fma(z, z, z) * z)) * x_m;
} else {
tmp = y / ((z / x_m) * 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 (Float64(Float64(x_m * y) / Float64(Float64(z * z) * Float64(z + 1.0))) <= 5e+109) tmp = Float64(Float64(y / Float64(fma(z, z, z) * z)) * x_m); else tmp = Float64(y / Float64(Float64(z / x_m) * z)); end return Float64(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[N[(N[(x$95$m * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+109], N[(N[(y / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision], N[(y / N[(N[(z / x$95$m), $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}\;\frac{x\_m \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \leq 5 \cdot 10^{+109}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(z, z, z\right) \cdot z} \cdot x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m} \cdot z}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) < 5.0000000000000001e109Initial program 91.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6497.8
Applied rewrites97.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
lift-fma.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
clear-numN/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
associate-/r/N/A
lift-fma.f64N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
Applied rewrites97.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-fma.f64N/A
distribute-lft-inN/A
*-lft-identityN/A
distribute-rgt-inN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*l*N/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
if 5.0000000000000001e109 < (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) Initial program 71.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6487.7
Applied rewrites87.7%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-/.f64N/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
lift-fma.f64N/A
clear-numN/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
*-lft-identityN/A
associate-*l/N/A
Applied rewrites82.3%
Taylor expanded in z around 0
lower-/.f6476.4
Applied rewrites76.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 (<= (/ (* x_m y) (* (* z z) (+ z 1.0))) 5e+109)
(* (/ y (* (fma z z z) z)) x_m)
(* (/ (/ 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 (((x_m * y) / ((z * z) * (z + 1.0))) <= 5e+109) {
tmp = (y / (fma(z, z, z) * z)) * x_m;
} 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 (Float64(Float64(x_m * y) / Float64(Float64(z * z) * Float64(z + 1.0))) <= 5e+109) tmp = Float64(Float64(y / Float64(fma(z, z, z) * z)) * x_m); else tmp = Float64(Float64(Float64(x_m / z) / z) * y); end return Float64(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[N[(N[(x$95$m * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+109], N[(N[(y / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision], N[(N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision] * y), $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}\;\frac{x\_m \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \leq 5 \cdot 10^{+109}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(z, z, z\right) \cdot z} \cdot x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x\_m}{z}}{z} \cdot y\\
\end{array}
\end{array}
if (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) < 5.0000000000000001e109Initial program 91.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6497.8
Applied rewrites97.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
lift-fma.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
clear-numN/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
associate-/r/N/A
lift-fma.f64N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
Applied rewrites97.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-fma.f64N/A
distribute-lft-inN/A
*-lft-identityN/A
distribute-rgt-inN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*l*N/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
if 5.0000000000000001e109 < (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) Initial program 71.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6482.3
Applied rewrites82.3%
Taylor expanded in z around 0
lower-/.f6476.3
Applied rewrites76.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 (<= (* (* z z) (+ z 1.0)) -5e+93)
(/ (/ y z) (* (/ z x_m) z))
(/ (* (/ x_m z) y) (fma z 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 * z) * (z + 1.0)) <= -5e+93) {
tmp = (y / z) / ((z / x_m) * z);
} else {
tmp = ((x_m / z) * y) / fma(z, 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 (Float64(Float64(z * z) * Float64(z + 1.0)) <= -5e+93) tmp = Float64(Float64(y / z) / Float64(Float64(z / x_m) * z)); else tmp = Float64(Float64(Float64(x_m / z) * y) / fma(z, z, z)); end return Float64(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[N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], -5e+93], N[(N[(y / z), $MachinePrecision] / N[(N[(z / x$95$m), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$95$m / z), $MachinePrecision] * y), $MachinePrecision] / N[(z * z + 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}\;\left(z \cdot z\right) \cdot \left(z + 1\right) \leq -5 \cdot 10^{+93}:\\
\;\;\;\;\frac{\frac{y}{z}}{\frac{z}{x\_m} \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x\_m}{z} \cdot y}{\mathsf{fma}\left(z, z, z\right)}\\
\end{array}
\end{array}
if (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) < -5.0000000000000001e93Initial program 83.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
lower-/.f6499.9
Applied rewrites99.9%
if -5.0000000000000001e93 < (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) Initial program 86.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/r*N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6497.4
Applied rewrites97.4%
Final simplification98.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 (<= (/ (* x_m y) (* (* z z) (+ z 1.0))) 0.0)
(* (/ (- x_m) z) y)
(* (/ (- y) z) x_m))))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 (((x_m * y) / ((z * z) * (z + 1.0))) <= 0.0) {
tmp = (-x_m / z) * y;
} else {
tmp = (-y / z) * x_m;
}
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 (((x_m * y) / ((z * z) * (z + 1.0d0))) <= 0.0d0) then
tmp = (-x_m / z) * y
else
tmp = (-y / z) * x_m
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 (((x_m * y) / ((z * z) * (z + 1.0))) <= 0.0) {
tmp = (-x_m / z) * y;
} else {
tmp = (-y / z) * x_m;
}
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 ((x_m * y) / ((z * z) * (z + 1.0))) <= 0.0: tmp = (-x_m / z) * y else: tmp = (-y / z) * x_m 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 (Float64(Float64(x_m * y) / Float64(Float64(z * z) * Float64(z + 1.0))) <= 0.0) tmp = Float64(Float64(Float64(-x_m) / z) * y); else tmp = Float64(Float64(Float64(-y) / z) * x_m); 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 (((x_m * y) / ((z * z) * (z + 1.0))) <= 0.0)
tmp = (-x_m / z) * y;
else
tmp = (-y / z) * x_m;
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[N[(N[(x$95$m * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[((-x$95$m) / z), $MachinePrecision] * y), $MachinePrecision], N[(N[((-y) / z), $MachinePrecision] * x$95$m), $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}\;\frac{x\_m \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \leq 0:\\
\;\;\;\;\frac{-x\_m}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{-y}{z} \cdot x\_m\\
\end{array}
\end{array}
if (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) < -0.0Initial program 90.4%
Taylor expanded in z around 0
*-lft-identityN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-/.f64N/A
distribute-lft-out--N/A
mul-1-negN/A
sub-negN/A
associate-*r*N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in z around inf
Applied rewrites39.2%
Taylor expanded in z around inf
Applied rewrites37.0%
if -0.0 < (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) Initial program 78.1%
Taylor expanded in z around 0
*-lft-identityN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-/.f64N/A
distribute-lft-out--N/A
mul-1-negN/A
sub-negN/A
associate-*r*N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6462.5
Applied rewrites62.5%
Taylor expanded in z around inf
Applied rewrites15.1%
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 z) (+ z 1.0)) 5e+30)
(* (/ (/ x_m (fma z z z)) z) y)
(/ (* (/ y z) 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 (((z * z) * (z + 1.0)) <= 5e+30) {
tmp = ((x_m / fma(z, z, z)) / z) * y;
} else {
tmp = ((y / z) * 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 (Float64(Float64(z * z) * Float64(z + 1.0)) <= 5e+30) tmp = Float64(Float64(Float64(x_m / fma(z, z, z)) / z) * y); else tmp = Float64(Float64(Float64(y / z) * x_m) / Float64(z * z)); end return Float64(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[N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], 5e+30], N[(N[(N[(x$95$m / N[(z * z + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] * x$95$m), $MachinePrecision] / N[(z * 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}\;\left(z \cdot z\right) \cdot \left(z + 1\right) \leq 5 \cdot 10^{+30}:\\
\;\;\;\;\frac{\frac{x\_m}{\mathsf{fma}\left(z, z, z\right)}}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z} \cdot x\_m}{z \cdot z}\\
\end{array}
\end{array}
if (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) < 4.9999999999999998e30Initial program 86.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6488.8
Applied rewrites88.8%
if 4.9999999999999998e30 < (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64))) Initial program 86.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6497.9
Applied rewrites97.9%
Taylor expanded in z around inf
unpow2N/A
lower-*.f6497.9
Applied rewrites97.9%
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 -5e-16)
(* (/ y (* (fma z z z) z)) x_m)
(if (<= z 3.2e-8) (* (/ (/ x_m z) z) y) (/ (* (/ y z) 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 (z <= -5e-16) {
tmp = (y / (fma(z, z, z) * z)) * x_m;
} else if (z <= 3.2e-8) {
tmp = ((x_m / z) / z) * y;
} else {
tmp = ((y / z) * 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 (z <= -5e-16) tmp = Float64(Float64(y / Float64(fma(z, z, z) * z)) * x_m); elseif (z <= 3.2e-8) tmp = Float64(Float64(Float64(x_m / z) / z) * y); else tmp = Float64(Float64(Float64(y / z) * x_m) / Float64(z * z)); end return Float64(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, -5e-16], N[(N[(y / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision], If[LessEqual[z, 3.2e-8], N[(N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] * x$95$m), $MachinePrecision] / N[(z * 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 -5 \cdot 10^{-16}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(z, z, z\right) \cdot z} \cdot x\_m\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{x\_m}{z}}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z} \cdot x\_m}{z \cdot z}\\
\end{array}
\end{array}
if z < -5.0000000000000004e-16Initial program 85.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6498.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.4
Applied rewrites98.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
lift-fma.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
clear-numN/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
associate-/r/N/A
lift-fma.f64N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
Applied rewrites93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-fma.f64N/A
distribute-lft-inN/A
*-lft-identityN/A
distribute-rgt-inN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*l*N/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
if -5.0000000000000004e-16 < z < 3.2000000000000002e-8Initial program 86.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6487.4
Applied rewrites87.4%
Taylor expanded in z around 0
lower-/.f6487.2
Applied rewrites87.2%
if 3.2000000000000002e-8 < z Initial program 86.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6498.0
Applied rewrites98.0%
Taylor expanded in z around inf
unpow2N/A
lower-*.f6497.5
Applied rewrites97.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 (/ (/ y (+ z 1.0)) (* (/ z x_m) 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 + 1.0)) / ((z / x_m) * 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 + 1.0d0)) / ((z / x_m) * 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 + 1.0)) / ((z / x_m) * 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 + 1.0)) / ((z / x_m) * 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 / Float64(z + 1.0)) / Float64(Float64(z / x_m) * 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 + 1.0)) / ((z / x_m) * 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 / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(z / x$95$m), $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 \frac{\frac{y}{z + 1}}{\frac{z}{x\_m} \cdot z}
\end{array}
Initial program 86.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6493.5
Applied rewrites93.5%
Final simplification93.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
(let* ((t_0 (* (/ y (* (fma z z z) z)) x_m)))
(*
x_s
(if (<= z -3.4e-34) t_0 (if (<= z 1.2e-14) (* (/ x_m z) (/ y z)) t_0)))))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 t_0 = (y / (fma(z, z, z) * z)) * x_m;
double tmp;
if (z <= -3.4e-34) {
tmp = t_0;
} else if (z <= 1.2e-14) {
tmp = (x_m / z) * (y / z);
} else {
tmp = t_0;
}
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) t_0 = Float64(Float64(y / Float64(fma(z, z, z) * z)) * x_m) tmp = 0.0 if (z <= -3.4e-34) tmp = t_0; elseif (z <= 1.2e-14) tmp = Float64(Float64(x_m / z) * Float64(y / z)); else tmp = t_0; end return Float64(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_] := Block[{t$95$0 = N[(N[(y / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, -3.4e-34], t$95$0, If[LessEqual[z, 1.2e-14], N[(N[(x$95$m / z), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], t$95$0]]), $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])\\
\\
\begin{array}{l}
t_0 := \frac{y}{\mathsf{fma}\left(z, z, z\right) \cdot z} \cdot x\_m\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-14}:\\
\;\;\;\;\frac{x\_m}{z} \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if z < -3.4000000000000001e-34 or 1.2e-14 < z Initial program 86.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.1
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.1
Applied rewrites99.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
lift-fma.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
clear-numN/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
associate-/r/N/A
lift-fma.f64N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
lift-+.f64N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
Applied rewrites94.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-fma.f64N/A
distribute-lft-inN/A
*-lft-identityN/A
distribute-rgt-inN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*l*N/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f6488.2
Applied rewrites88.2%
if -3.4000000000000001e-34 < z < 1.2e-14Initial program 85.6%
Taylor expanded in z around 0
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6498.4
Applied rewrites98.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 (<= (* x_m y) 2e-144)
(* (/ x_m z) (/ y z))
(* (/ x_m (* (fma z z 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 ((x_m * y) <= 2e-144) {
tmp = (x_m / z) * (y / z);
} else {
tmp = (x_m / (fma(z, z, 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 (Float64(x_m * y) <= 2e-144) tmp = Float64(Float64(x_m / z) * Float64(y / z)); else tmp = Float64(Float64(x_m / Float64(fma(z, z, z) * z)) * y); end return Float64(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[N[(x$95$m * y), $MachinePrecision], 2e-144], N[(N[(x$95$m / z), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * y), $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}\;x\_m \cdot y \leq 2 \cdot 10^{-144}:\\
\;\;\;\;\frac{x\_m}{z} \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{\mathsf{fma}\left(z, z, z\right) \cdot z} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < 1.9999999999999999e-144Initial program 83.7%
Taylor expanded in z around 0
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6479.9
Applied rewrites79.9%
if 1.9999999999999999e-144 < (*.f64 x y) Initial program 91.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6492.6
Applied rewrites92.6%
lift-/.f64N/A
lift-/.f64N/A
frac-2negN/A
associate-/l/N/A
lift-fma.f64N/A
*-lft-identityN/A
distribute-rgt-inN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
frac-2negN/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f6487.7
Applied rewrites87.7%
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 (<= (* x_m y) 2e-144) (* (/ x_m z) (/ y 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 ((x_m * y) <= 2e-144) {
tmp = (x_m / z) * (y / 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 ((x_m * y) <= 2d-144) then
tmp = (x_m / z) * (y / 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 ((x_m * y) <= 2e-144) {
tmp = (x_m / z) * (y / 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 (x_m * y) <= 2e-144: tmp = (x_m / z) * (y / 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 (Float64(x_m * y) <= 2e-144) tmp = Float64(Float64(x_m / z) * Float64(y / z)); else tmp = Float64(Float64(x_m / Float64(z * 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 ((x_m * y) <= 2e-144)
tmp = (x_m / z) * (y / 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[LessEqual[N[(x$95$m * y), $MachinePrecision], 2e-144], N[(N[(x$95$m / z), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision] * y), $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}\;x\_m \cdot y \leq 2 \cdot 10^{-144}:\\
\;\;\;\;\frac{x\_m}{z} \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{z \cdot z} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < 1.9999999999999999e-144Initial program 83.7%
Taylor expanded in z around 0
unpow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6479.9
Applied rewrites79.9%
if 1.9999999999999999e-144 < (*.f64 x y) Initial program 91.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6492.6
Applied rewrites92.6%
Taylor expanded in z around 0
lower-/.f64N/A
unpow2N/A
lower-*.f6474.6
Applied rewrites74.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 (/ (* (/ x_m z) y) (fma z 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 * (((x_m / z) * y) / fma(z, 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(Float64(Float64(x_m / z) * y) / fma(z, 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[(N[(N[(x$95$m / z), $MachinePrecision] * y), $MachinePrecision] / N[(z * z + 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 \frac{\frac{x\_m}{z} \cdot y}{\mathsf{fma}\left(z, z, z\right)}
\end{array}
Initial program 86.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/r*N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6496.0
Applied rewrites96.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 (* (/ 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) {
return x_s * ((x_m / (z * z)) * y);
}
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 * z)) * y)
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 * z)) * y);
}
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 * z)) * y)
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(x_m / Float64(z * z)) * y)) 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 * z)) * y);
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[(x$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision] * y), $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{x\_m}{z \cdot z} \cdot y\right)
\end{array}
Initial program 86.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft1-inN/A
lower-fma.f6489.8
Applied rewrites89.8%
Taylor expanded in z around 0
lower-/.f64N/A
unpow2N/A
lower-*.f6473.1
Applied rewrites73.1%
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)))
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);
}
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)
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);
}
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)
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) * y)) 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);
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[((-x$95$m) / z), $MachinePrecision] * y), $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{-x\_m}{z} \cdot y\right)
\end{array}
Initial program 86.0%
Taylor expanded in z around 0
*-lft-identityN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-/.f64N/A
distribute-lft-out--N/A
mul-1-negN/A
sub-negN/A
associate-*r*N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6467.2
Applied rewrites67.2%
Taylor expanded in z around inf
Applied rewrites30.5%
Taylor expanded in z around inf
Applied rewrites29.4%
(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 2024255
(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))))