
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 2e-26) (- x_m (* (* x_m y) z)) (- x_m (* x_m (* y 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 <= 2e-26) {
tmp = x_m - ((x_m * y) * z);
} else {
tmp = x_m - (x_m * (y * 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 (x_m <= 2d-26) then
tmp = x_m - ((x_m * y) * z)
else
tmp = x_m - (x_m * (y * 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 (x_m <= 2e-26) {
tmp = x_m - ((x_m * y) * z);
} else {
tmp = x_m - (x_m * (y * 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 x_m <= 2e-26: tmp = x_m - ((x_m * y) * z) else: tmp = x_m - (x_m * (y * 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 (x_m <= 2e-26) tmp = Float64(x_m - Float64(Float64(x_m * y) * z)); else tmp = Float64(x_m - Float64(x_m * Float64(y * 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 (x_m <= 2e-26)
tmp = x_m - ((x_m * y) * z);
else
tmp = x_m - (x_m * (y * 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[x$95$m, 2e-26], N[(x$95$m - N[(N[(x$95$m * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m * N[(y * z), $MachinePrecision]), $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}\;x_m \leq 2 \cdot 10^{-26}:\\
\;\;\;\;x_m - \left(x_m \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x_m - x_m \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if x < 2.0000000000000001e-26Initial program 95.8%
sub-neg95.8%
distribute-rgt-in95.8%
*-un-lft-identity95.8%
distribute-rgt-neg-in95.8%
Applied egg-rr95.8%
Taylor expanded in y around 0 95.8%
neg-mul-195.8%
associate-*r*94.9%
Simplified94.9%
if 2.0000000000000001e-26 < x Initial program 99.9%
sub-neg99.9%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
distribute-rgt-neg-in100.0%
Applied egg-rr100.0%
distribute-rgt-neg-out100.0%
distribute-lft-neg-out100.0%
associate-*r*88.7%
*-commutative88.7%
distribute-lft-neg-in88.7%
add-sqr-sqrt36.3%
sqrt-unprod60.7%
sqr-neg60.7%
sqrt-unprod33.1%
add-sqr-sqrt50.7%
*-commutative50.7%
distribute-lft-neg-in50.7%
cancel-sign-sub-inv50.7%
associate-*l*55.0%
*-commutative55.0%
add-sqr-sqrt34.8%
sqrt-unprod75.1%
distribute-rgt-neg-out75.1%
distribute-rgt-neg-out75.1%
sqr-neg75.1%
sqrt-prod58.2%
Applied egg-rr100.0%
Final simplification96.2%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 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 -7.5e+168)
(* x_m (* y (- z)))
(if (or (<= y -1.9e+62) (not (<= y 2e-153))) (* y (* x_m (- 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 (y <= -7.5e+168) {
tmp = x_m * (y * -z);
} else if ((y <= -1.9e+62) || !(y <= 2e-153)) {
tmp = y * (x_m * -z);
} else {
tmp = 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 (y <= (-7.5d+168)) then
tmp = x_m * (y * -z)
else if ((y <= (-1.9d+62)) .or. (.not. (y <= 2d-153))) then
tmp = y * (x_m * -z)
else
tmp = 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 (y <= -7.5e+168) {
tmp = x_m * (y * -z);
} else if ((y <= -1.9e+62) || !(y <= 2e-153)) {
tmp = y * (x_m * -z);
} else {
tmp = 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 y <= -7.5e+168: tmp = x_m * (y * -z) elif (y <= -1.9e+62) or not (y <= 2e-153): tmp = y * (x_m * -z) else: tmp = 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 (y <= -7.5e+168) tmp = Float64(x_m * Float64(y * Float64(-z))); elseif ((y <= -1.9e+62) || !(y <= 2e-153)) tmp = Float64(y * Float64(x_m * Float64(-z))); else tmp = 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 (y <= -7.5e+168)
tmp = x_m * (y * -z);
elseif ((y <= -1.9e+62) || ~((y <= 2e-153)))
tmp = y * (x_m * -z);
else
tmp = 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[y, -7.5e+168], N[(x$95$m * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -1.9e+62], N[Not[LessEqual[y, 2e-153]], $MachinePrecision]], N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision], x$95$m]]), $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 -7.5 \cdot 10^{+168}:\\
\;\;\;\;x_m \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{+62} \lor \neg \left(y \leq 2 \cdot 10^{-153}\right):\\
\;\;\;\;y \cdot \left(x_m \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if y < -7.4999999999999999e168Initial program 96.9%
Taylor expanded in y around inf 69.5%
mul-1-neg69.5%
distribute-rgt-neg-in69.5%
distribute-rgt-neg-out69.5%
Simplified69.5%
if -7.4999999999999999e168 < y < -1.89999999999999992e62 or 2.00000000000000008e-153 < y Initial program 93.9%
Taylor expanded in y around inf 66.6%
mul-1-neg66.6%
associate-*r*71.7%
distribute-rgt-neg-in71.7%
*-commutative71.7%
associate-*r*69.1%
distribute-rgt-neg-out69.1%
Simplified69.1%
if -1.89999999999999992e62 < y < 2.00000000000000008e-153Initial program 99.9%
Taylor expanded in y around 0 79.2%
Final simplification73.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 (<= y -4e+60) (not (<= y 2e-153))) (* x_m (* 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 ((y <= -4e+60) || !(y <= 2e-153)) {
tmp = x_m * (y * -z);
} else {
tmp = 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 ((y <= (-4d+60)) .or. (.not. (y <= 2d-153))) then
tmp = x_m * (y * -z)
else
tmp = 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 ((y <= -4e+60) || !(y <= 2e-153)) {
tmp = x_m * (y * -z);
} else {
tmp = 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 (y <= -4e+60) or not (y <= 2e-153): tmp = x_m * (y * -z) else: tmp = 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 ((y <= -4e+60) || !(y <= 2e-153)) tmp = Float64(x_m * Float64(y * Float64(-z))); else tmp = 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 ((y <= -4e+60) || ~((y <= 2e-153)))
tmp = x_m * (y * -z);
else
tmp = 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[Or[LessEqual[y, -4e+60], N[Not[LessEqual[y, 2e-153]], $MachinePrecision]], N[(x$95$m * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], x$95$m]), $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 -4 \cdot 10^{+60} \lor \neg \left(y \leq 2 \cdot 10^{-153}\right):\\
\;\;\;\;x_m \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if y < -3.9999999999999998e60 or 2.00000000000000008e-153 < y Initial program 94.5%
Taylor expanded in y around inf 67.2%
mul-1-neg67.2%
distribute-rgt-neg-in67.2%
distribute-rgt-neg-out67.2%
Simplified67.2%
if -3.9999999999999998e60 < y < 2.00000000000000008e-153Initial program 99.9%
Taylor expanded in y around 0 79.2%
Final simplification72.4%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 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 -2.35e+62)
(* (* x_m y) (- z))
(if (<= y 2e-153) x_m (* y (* 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 (y <= -2.35e+62) {
tmp = (x_m * y) * -z;
} else if (y <= 2e-153) {
tmp = x_m;
} else {
tmp = y * (x_m * -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 <= (-2.35d+62)) then
tmp = (x_m * y) * -z
else if (y <= 2d-153) then
tmp = x_m
else
tmp = y * (x_m * -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 <= -2.35e+62) {
tmp = (x_m * y) * -z;
} else if (y <= 2e-153) {
tmp = x_m;
} else {
tmp = y * (x_m * -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 <= -2.35e+62: tmp = (x_m * y) * -z elif y <= 2e-153: tmp = x_m else: tmp = y * (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 (y <= -2.35e+62) tmp = Float64(Float64(x_m * y) * Float64(-z)); elseif (y <= 2e-153) tmp = x_m; else tmp = Float64(y * Float64(x_m * Float64(-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 <= -2.35e+62)
tmp = (x_m * y) * -z;
elseif (y <= 2e-153)
tmp = x_m;
else
tmp = y * (x_m * -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, -2.35e+62], N[(N[(x$95$m * y), $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[y, 2e-153], x$95$m, N[(y * N[(x$95$m * (-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.35 \cdot 10^{+62}:\\
\;\;\;\;\left(x_m \cdot y\right) \cdot \left(-z\right)\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-153}:\\
\;\;\;\;x_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x_m \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if y < -2.3500000000000001e62Initial program 95.9%
sub-neg95.9%
distribute-rgt-in96.0%
*-un-lft-identity96.0%
distribute-rgt-neg-in96.0%
Applied egg-rr96.0%
distribute-rgt-neg-out96.0%
distribute-lft-neg-out96.0%
associate-*r*92.8%
*-commutative92.8%
distribute-lft-neg-in92.8%
add-sqr-sqrt49.9%
sqrt-unprod53.7%
sqr-neg53.7%
sqrt-unprod15.7%
add-sqr-sqrt22.9%
*-commutative22.9%
distribute-lft-neg-in22.9%
cancel-sign-sub-inv22.9%
associate-*l*22.7%
*-commutative22.7%
add-sqr-sqrt8.3%
sqrt-unprod47.4%
distribute-rgt-neg-out47.4%
distribute-rgt-neg-out47.4%
sqr-neg47.4%
sqrt-prod43.0%
Applied egg-rr96.0%
Taylor expanded in y around inf 70.6%
*-commutative70.6%
associate-*r*70.6%
mul-1-neg70.6%
distribute-rgt-neg-out70.6%
*-commutative70.6%
associate-*r*70.4%
*-commutative70.4%
Simplified70.4%
if -2.3500000000000001e62 < y < 2.00000000000000008e-153Initial program 99.9%
Taylor expanded in y around 0 79.2%
if 2.00000000000000008e-153 < y Initial program 93.8%
Taylor expanded in y around inf 65.4%
mul-1-neg65.4%
associate-*r*70.5%
distribute-rgt-neg-in70.5%
*-commutative70.5%
associate-*r*67.3%
distribute-rgt-neg-out67.3%
Simplified67.3%
Final simplification73.1%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 z) -5e+155) (* y (* x_m (- z))) (* x_m (- 1.0 (* y 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 * z) <= -5e+155) {
tmp = y * (x_m * -z);
} else {
tmp = x_m * (1.0 - (y * 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 * z) <= (-5d+155)) then
tmp = y * (x_m * -z)
else
tmp = x_m * (1.0d0 - (y * 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 * z) <= -5e+155) {
tmp = y * (x_m * -z);
} else {
tmp = x_m * (1.0 - (y * 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 * z) <= -5e+155: tmp = y * (x_m * -z) else: tmp = x_m * (1.0 - (y * 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(y * z) <= -5e+155) tmp = Float64(y * Float64(x_m * Float64(-z))); else tmp = Float64(x_m * Float64(1.0 - Float64(y * 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 * z) <= -5e+155)
tmp = y * (x_m * -z);
else
tmp = x_m * (1.0 - (y * 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[N[(y * z), $MachinePrecision], -5e+155], N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 - N[(y * z), $MachinePrecision]), $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 \cdot z \leq -5 \cdot 10^{+155}:\\
\;\;\;\;y \cdot \left(x_m \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x_m \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -4.9999999999999999e155Initial program 84.6%
Taylor expanded in y around inf 84.6%
mul-1-neg84.6%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-rgt-neg-out99.9%
Simplified99.9%
if -4.9999999999999999e155 < (*.f64 y z) Initial program 98.6%
Final simplification98.8%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 z) -5e+155) (* y (* x_m (- z))) (- x_m (* x_m (* y 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 * z) <= -5e+155) {
tmp = y * (x_m * -z);
} else {
tmp = x_m - (x_m * (y * 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 * z) <= (-5d+155)) then
tmp = y * (x_m * -z)
else
tmp = x_m - (x_m * (y * 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 * z) <= -5e+155) {
tmp = y * (x_m * -z);
} else {
tmp = x_m - (x_m * (y * 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 * z) <= -5e+155: tmp = y * (x_m * -z) else: tmp = x_m - (x_m * (y * 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(y * z) <= -5e+155) tmp = Float64(y * Float64(x_m * Float64(-z))); else tmp = Float64(x_m - Float64(x_m * Float64(y * 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 * z) <= -5e+155)
tmp = y * (x_m * -z);
else
tmp = x_m - (x_m * (y * 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[N[(y * z), $MachinePrecision], -5e+155], N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m * N[(y * z), $MachinePrecision]), $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 \cdot z \leq -5 \cdot 10^{+155}:\\
\;\;\;\;y \cdot \left(x_m \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x_m - x_m \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -4.9999999999999999e155Initial program 84.6%
Taylor expanded in y around inf 84.6%
mul-1-neg84.6%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-rgt-neg-out99.9%
Simplified99.9%
if -4.9999999999999999e155 < (*.f64 y z) Initial program 98.6%
sub-neg98.6%
distribute-rgt-in98.6%
*-un-lft-identity98.6%
distribute-rgt-neg-in98.6%
Applied egg-rr98.6%
distribute-rgt-neg-out98.6%
distribute-lft-neg-out98.6%
associate-*r*92.4%
*-commutative92.4%
distribute-lft-neg-in92.4%
add-sqr-sqrt47.0%
sqrt-unprod62.3%
sqr-neg62.3%
sqrt-unprod32.4%
add-sqr-sqrt54.3%
*-commutative54.3%
distribute-lft-neg-in54.3%
cancel-sign-sub-inv54.3%
associate-*l*56.0%
*-commutative56.0%
add-sqr-sqrt35.6%
sqrt-unprod80.1%
distribute-rgt-neg-out80.1%
distribute-rgt-neg-out80.1%
sqr-neg80.1%
sqrt-prod63.9%
Applied egg-rr98.6%
Final simplification98.8%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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))
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;
}
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
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;
}
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
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 * x_m) 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;
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 * x$95$m), $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 x_m
\end{array}
Initial program 96.9%
Taylor expanded in y around 0 50.7%
Final simplification50.7%
herbie shell --seed 2024021
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))