
(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 6 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-58) (- x_m (* 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 (x_m <= 2e-58) {
tmp = x_m - (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 (x_m <= 2d-58) then
tmp = x_m - (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 (x_m <= 2e-58) {
tmp = x_m - (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 x_m <= 2e-58: tmp = x_m - (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 (x_m <= 2e-58) tmp = Float64(x_m - Float64(y * Float64(x_m * 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-58)
tmp = x_m - (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[x$95$m, 2e-58], N[(x$95$m - N[(y * N[(x$95$m * z), $MachinePrecision]), $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^{-58}:\\
\;\;\;\;x_m - y \cdot \left(x_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x_m - x_m \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if x < 2.0000000000000001e-58Initial program 96.2%
sub-neg96.2%
distribute-rgt-in96.2%
*-un-lft-identity96.2%
distribute-rgt-neg-in96.2%
Applied egg-rr96.2%
*-commutative96.2%
*-commutative96.2%
associate-*r*94.8%
distribute-rgt-neg-in94.8%
distribute-lft-neg-in94.8%
associate-*l*96.2%
*-commutative96.2%
add-sqr-sqrt56.1%
sqrt-prod71.2%
sqr-neg71.2%
distribute-rgt-neg-out71.2%
distribute-rgt-neg-out71.2%
sqrt-unprod32.2%
add-sqr-sqrt54.4%
cancel-sign-sub-inv54.4%
add-sqr-sqrt32.2%
sqrt-unprod71.2%
distribute-rgt-neg-out71.2%
distribute-rgt-neg-out71.2%
sqr-neg71.2%
Applied egg-rr96.2%
expm1-log1p-u77.4%
expm1-udef66.1%
Applied egg-rr66.1%
expm1-def77.4%
expm1-log1p96.2%
*-commutative96.2%
associate-*l*94.8%
*-commutative94.8%
Simplified94.8%
if 2.0000000000000001e-58 < 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%
*-commutative100.0%
*-commutative100.0%
associate-*r*91.6%
distribute-rgt-neg-in91.6%
distribute-lft-neg-in91.6%
associate-*l*100.0%
*-commutative100.0%
add-sqr-sqrt58.9%
sqrt-prod79.9%
sqr-neg79.9%
distribute-rgt-neg-out79.9%
distribute-rgt-neg-out79.9%
sqrt-unprod38.9%
add-sqr-sqrt60.1%
cancel-sign-sub-inv60.1%
add-sqr-sqrt38.9%
sqrt-unprod79.9%
distribute-rgt-neg-out79.9%
distribute-rgt-neg-out79.9%
sqr-neg79.9%
Applied egg-rr100.0%
Final simplification96.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 (or (<= z -1.22e-88)
(and (not (<= z 1.45e+43))
(or (<= z 1.05e+72) (not (<= z 2.36e+111)))))
(* x_m (* z (- y)))
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 ((z <= -1.22e-88) || (!(z <= 1.45e+43) && ((z <= 1.05e+72) || !(z <= 2.36e+111)))) {
tmp = x_m * (z * -y);
} 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 ((z <= (-1.22d-88)) .or. (.not. (z <= 1.45d+43)) .and. (z <= 1.05d+72) .or. (.not. (z <= 2.36d+111))) then
tmp = x_m * (z * -y)
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 ((z <= -1.22e-88) || (!(z <= 1.45e+43) && ((z <= 1.05e+72) || !(z <= 2.36e+111)))) {
tmp = x_m * (z * -y);
} 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 (z <= -1.22e-88) or (not (z <= 1.45e+43) and ((z <= 1.05e+72) or not (z <= 2.36e+111))): tmp = x_m * (z * -y) 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 ((z <= -1.22e-88) || (!(z <= 1.45e+43) && ((z <= 1.05e+72) || !(z <= 2.36e+111)))) tmp = Float64(x_m * Float64(z * Float64(-y))); 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 ((z <= -1.22e-88) || (~((z <= 1.45e+43)) && ((z <= 1.05e+72) || ~((z <= 2.36e+111)))))
tmp = x_m * (z * -y);
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[z, -1.22e-88], And[N[Not[LessEqual[z, 1.45e+43]], $MachinePrecision], Or[LessEqual[z, 1.05e+72], N[Not[LessEqual[z, 2.36e+111]], $MachinePrecision]]]], N[(x$95$m * N[(z * (-y)), $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}\;z \leq -1.22 \cdot 10^{-88} \lor \neg \left(z \leq 1.45 \cdot 10^{+43}\right) \land \left(z \leq 1.05 \cdot 10^{+72} \lor \neg \left(z \leq 2.36 \cdot 10^{+111}\right)\right):\\
\;\;\;\;x_m \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if z < -1.2200000000000001e-88 or 1.4500000000000001e43 < z < 1.0500000000000001e72 or 2.3599999999999999e111 < z Initial program 94.4%
Taylor expanded in y around inf 56.6%
mul-1-neg56.6%
distribute-rgt-neg-in56.6%
distribute-rgt-neg-out56.6%
Simplified56.6%
if -1.2200000000000001e-88 < z < 1.4500000000000001e43 or 1.0500000000000001e72 < z < 2.3599999999999999e111Initial program 100.0%
Taylor expanded in y around 0 77.0%
Final simplification67.3%
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.4e+147)
(* y (* x_m (- z)))
(if (<= y 5.1e-169) x_m (* z (* y (- 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 <= -2.4e+147) {
tmp = y * (x_m * -z);
} else if (y <= 5.1e-169) {
tmp = x_m;
} else {
tmp = z * (y * -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 <= (-2.4d+147)) then
tmp = y * (x_m * -z)
else if (y <= 5.1d-169) then
tmp = x_m
else
tmp = z * (y * -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 <= -2.4e+147) {
tmp = y * (x_m * -z);
} else if (y <= 5.1e-169) {
tmp = x_m;
} else {
tmp = z * (y * -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 <= -2.4e+147: tmp = y * (x_m * -z) elif y <= 5.1e-169: tmp = x_m else: tmp = z * (y * -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 <= -2.4e+147) tmp = Float64(y * Float64(x_m * Float64(-z))); elseif (y <= 5.1e-169) tmp = x_m; else tmp = Float64(z * Float64(y * Float64(-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 <= -2.4e+147)
tmp = y * (x_m * -z);
elseif (y <= 5.1e-169)
tmp = x_m;
else
tmp = z * (y * -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, -2.4e+147], N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.1e-169], x$95$m, N[(z * N[(y * (-x$95$m)), $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.4 \cdot 10^{+147}:\\
\;\;\;\;y \cdot \left(x_m \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{-169}:\\
\;\;\;\;x_m\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x_m\right)\right)\\
\end{array}
\end{array}
if y < -2.40000000000000002e147Initial program 99.8%
Taylor expanded in y around inf 82.9%
mul-1-neg82.9%
associate-*r*73.5%
distribute-rgt-neg-in73.5%
*-commutative73.5%
associate-*r*81.8%
distribute-rgt-neg-out81.8%
Simplified81.8%
if -2.40000000000000002e147 < y < 5.09999999999999997e-169Initial program 99.9%
Taylor expanded in y around 0 74.5%
if 5.09999999999999997e-169 < y Initial program 91.8%
flip--75.6%
associate-*r/72.2%
metadata-eval72.2%
pow272.2%
+-commutative72.2%
fma-def72.2%
Applied egg-rr72.2%
associate-/l*75.5%
Simplified75.5%
Taylor expanded in y around inf 49.2%
div-inv49.3%
frac-2neg49.3%
metadata-eval49.3%
remove-double-div49.3%
distribute-rgt-neg-in49.3%
associate-*r*52.8%
*-commutative52.8%
distribute-rgt-neg-in52.8%
*-commutative52.8%
Applied egg-rr52.8%
Final simplification68.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 z) -1e+254) (* 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) <= -1e+254) {
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) <= (-1d+254)) 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) <= -1e+254) {
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) <= -1e+254: 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) <= -1e+254) 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) <= -1e+254)
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], -1e+254], 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 -1 \cdot 10^{+254}:\\
\;\;\;\;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) < -9.9999999999999994e253Initial program 77.5%
Taylor expanded in y around inf 77.5%
mul-1-neg77.5%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
*-commutative99.9%
associate-*r*99.8%
distribute-rgt-neg-out99.8%
Simplified99.8%
if -9.9999999999999994e253 < (*.f64 y z) Initial program 99.1%
Final simplification99.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 z) -1e+254) (* 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) <= -1e+254) {
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) <= (-1d+254)) 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) <= -1e+254) {
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) <= -1e+254: 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) <= -1e+254) 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) <= -1e+254)
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], -1e+254], 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 -1 \cdot 10^{+254}:\\
\;\;\;\;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) < -9.9999999999999994e253Initial program 77.5%
Taylor expanded in y around inf 77.5%
mul-1-neg77.5%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
*-commutative99.9%
associate-*r*99.8%
distribute-rgt-neg-out99.8%
Simplified99.8%
if -9.9999999999999994e253 < (*.f64 y z) Initial program 99.1%
sub-neg99.1%
distribute-rgt-in99.1%
*-un-lft-identity99.1%
distribute-rgt-neg-in99.1%
Applied egg-rr99.1%
*-commutative99.1%
*-commutative99.1%
associate-*r*93.3%
distribute-rgt-neg-in93.3%
distribute-lft-neg-in93.3%
associate-*l*99.1%
*-commutative99.1%
add-sqr-sqrt62.0%
sqrt-prod80.4%
sqr-neg80.4%
distribute-rgt-neg-out80.4%
distribute-rgt-neg-out80.4%
sqrt-unprod37.3%
add-sqr-sqrt61.1%
cancel-sign-sub-inv61.1%
add-sqr-sqrt37.3%
sqrt-unprod80.4%
distribute-rgt-neg-out80.4%
distribute-rgt-neg-out80.4%
sqr-neg80.4%
Applied egg-rr99.1%
Final simplification99.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 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 97.3%
Taylor expanded in y around 0 57.4%
Final simplification57.4%
herbie shell --seed 2024019
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))