
(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 8 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 #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 2.3e-42) (- x_m (* (* x_m z) y)) (- x_m (* 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) {
double tmp;
if (x_m <= 2.3e-42) {
tmp = x_m - ((x_m * z) * y);
} else {
tmp = x_m - (x_m * (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 <= 2.3d-42) then
tmp = x_m - ((x_m * z) * y)
else
tmp = x_m - (x_m * (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 <= 2.3e-42) {
tmp = x_m - ((x_m * z) * y);
} else {
tmp = x_m - (x_m * (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 <= 2.3e-42: tmp = x_m - ((x_m * z) * y) else: tmp = x_m - (x_m * (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 (x_m <= 2.3e-42) tmp = Float64(x_m - Float64(Float64(x_m * z) * y)); else tmp = Float64(x_m - Float64(x_m * Float64(z * y))); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (x_m <= 2.3e-42)
tmp = x_m - ((x_m * z) * y);
else
tmp = x_m - (x_m * (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[x$95$m, 2.3e-42], N[(x$95$m - N[(N[(x$95$m * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m * N[(z * y), $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.3 \cdot 10^{-42}:\\
\;\;\;\;x\_m - \left(x\_m \cdot z\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if x < 2.30000000000000004e-42Initial program 93.5%
Taylor expanded in z around inf 89.0%
Taylor expanded in z around 0 93.5%
associate-*r*96.7%
*-commutative96.7%
neg-mul-196.7%
sub-neg96.7%
associate-*r*89.6%
*-commutative89.6%
Simplified89.6%
if 2.30000000000000004e-42 < x Initial program 99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-rgt-neg-in99.9%
Applied egg-rr99.9%
Final simplification92.8%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= z -4.9e-67)
(* y (* x_m (- z)))
(if (<= z 5.1e+61)
x_m
(if (<= z 1.05e+226) (* z (* x_m (- y))) (* 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) {
double tmp;
if (z <= -4.9e-67) {
tmp = y * (x_m * -z);
} else if (z <= 5.1e+61) {
tmp = x_m;
} else if (z <= 1.05e+226) {
tmp = z * (x_m * -y);
} else {
tmp = x_m * (z * -y);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-4.9d-67)) then
tmp = y * (x_m * -z)
else if (z <= 5.1d+61) then
tmp = x_m
else if (z <= 1.05d+226) then
tmp = z * (x_m * -y)
else
tmp = x_m * (z * -y)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -4.9e-67) {
tmp = y * (x_m * -z);
} else if (z <= 5.1e+61) {
tmp = x_m;
} else if (z <= 1.05e+226) {
tmp = z * (x_m * -y);
} else {
tmp = x_m * (z * -y);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if z <= -4.9e-67: tmp = y * (x_m * -z) elif z <= 5.1e+61: tmp = x_m elif z <= 1.05e+226: tmp = z * (x_m * -y) else: tmp = x_m * (z * -y) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (z <= -4.9e-67) tmp = Float64(y * Float64(x_m * Float64(-z))); elseif (z <= 5.1e+61) tmp = x_m; elseif (z <= 1.05e+226) tmp = Float64(z * Float64(x_m * Float64(-y))); else tmp = Float64(x_m * Float64(z * Float64(-y))); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (z <= -4.9e-67)
tmp = y * (x_m * -z);
elseif (z <= 5.1e+61)
tmp = x_m;
elseif (z <= 1.05e+226)
tmp = z * (x_m * -y);
else
tmp = x_m * (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[z, -4.9e-67], N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.1e+61], x$95$m, If[LessEqual[z, 1.05e+226], N[(z * N[(x$95$m * (-y)), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(z * (-y)), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{-67}:\\
\;\;\;\;y \cdot \left(x\_m \cdot \left(-z\right)\right)\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{+61}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+226}:\\
\;\;\;\;z \cdot \left(x\_m \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(z \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if z < -4.89999999999999993e-67Initial program 91.4%
Taylor expanded in y around inf 56.3%
mul-1-neg56.3%
associate-*r*62.5%
distribute-rgt-neg-in62.5%
*-commutative62.5%
associate-*l*62.5%
Simplified62.5%
if -4.89999999999999993e-67 < z < 5.1000000000000001e61Initial program 99.9%
Taylor expanded in y around 0 74.0%
if 5.1000000000000001e61 < z < 1.04999999999999997e226Initial program 88.3%
Taylor expanded in z around inf 99.3%
Taylor expanded in y around inf 88.3%
neg-mul-188.3%
*-commutative88.3%
distribute-rgt-neg-in88.3%
Simplified88.3%
if 1.04999999999999997e226 < z Initial program 99.8%
Taylor expanded in y around inf 95.0%
mul-1-neg95.0%
distribute-rgt-neg-in95.0%
distribute-rgt-neg-out95.0%
Simplified95.0%
Final simplification73.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -3e-65) (not (<= z 3.8e+59))) (* 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 ((z <= -3e-65) || !(z <= 3.8e+59)) {
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 ((z <= (-3d-65)) .or. (.not. (z <= 3.8d+59))) 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 ((z <= -3e-65) || !(z <= 3.8e+59)) {
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 (z <= -3e-65) or not (z <= 3.8e+59): 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 ((z <= -3e-65) || !(z <= 3.8e+59)) 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 ((z <= -3e-65) || ~((z <= 3.8e+59)))
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[Or[LessEqual[z, -3e-65], N[Not[LessEqual[z, 3.8e+59]], $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}\;z \leq -3 \cdot 10^{-65} \lor \neg \left(z \leq 3.8 \cdot 10^{+59}\right):\\
\;\;\;\;y \cdot \left(x\_m \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -2.99999999999999998e-65 or 3.8000000000000001e59 < z Initial program 91.8%
Taylor expanded in y around inf 66.1%
mul-1-neg66.1%
associate-*r*72.1%
distribute-rgt-neg-in72.1%
*-commutative72.1%
associate-*l*68.8%
Simplified68.8%
if -2.99999999999999998e-65 < z < 3.8000000000000001e59Initial program 99.9%
Taylor expanded in y around 0 74.0%
Final simplification71.2%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -2.2e-65) (not (<= z 2.7e+60))) (* 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 <= -2.2e-65) || !(z <= 2.7e+60)) {
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 <= (-2.2d-65)) .or. (.not. (z <= 2.7d+60))) 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 <= -2.2e-65) || !(z <= 2.7e+60)) {
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 <= -2.2e-65) or not (z <= 2.7e+60): 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 <= -2.2e-65) || !(z <= 2.7e+60)) 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 <= -2.2e-65) || ~((z <= 2.7e+60)))
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, -2.2e-65], N[Not[LessEqual[z, 2.7e+60]], $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 -2.2 \cdot 10^{-65} \lor \neg \left(z \leq 2.7 \cdot 10^{+60}\right):\\
\;\;\;\;x\_m \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -2.20000000000000021e-65 or 2.6999999999999999e60 < z Initial program 91.8%
Taylor expanded in y around inf 66.1%
mul-1-neg66.1%
distribute-rgt-neg-in66.1%
distribute-rgt-neg-out66.1%
Simplified66.1%
if -2.20000000000000021e-65 < z < 2.6999999999999999e60Initial program 99.9%
Taylor expanded in y around 0 74.0%
Final simplification69.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 (<= (* z y) -4e+250) (* y (* x_m (- z))) (* x_m (- 1.0 (* z y))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z * y) <= -4e+250) {
tmp = y * (x_m * -z);
} else {
tmp = x_m * (1.0 - (z * y));
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * y) <= (-4d+250)) then
tmp = y * (x_m * -z)
else
tmp = x_m * (1.0d0 - (z * y))
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z * y) <= -4e+250) {
tmp = y * (x_m * -z);
} else {
tmp = x_m * (1.0 - (z * y));
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if (z * y) <= -4e+250: tmp = y * (x_m * -z) else: tmp = x_m * (1.0 - (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(z * y) <= -4e+250) tmp = Float64(y * Float64(x_m * Float64(-z))); else tmp = Float64(x_m * Float64(1.0 - Float64(z * y))); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if ((z * y) <= -4e+250)
tmp = y * (x_m * -z);
else
tmp = x_m * (1.0 - (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[(z * y), $MachinePrecision], -4e+250], N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 - N[(z * y), $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}\;z \cdot y \leq -4 \cdot 10^{+250}:\\
\;\;\;\;y \cdot \left(x\_m \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - z \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -3.9999999999999997e250Initial program 75.9%
Taylor expanded in y around inf 75.9%
mul-1-neg75.9%
associate-*r*96.9%
distribute-rgt-neg-in96.9%
*-commutative96.9%
associate-*l*99.9%
Simplified99.9%
if -3.9999999999999997e250 < (*.f64 y z) Initial program 98.1%
Final simplification98.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 4.3e-35) (- x_m (* (* x_m z) y)) (* x_m (- 1.0 (* 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 <= 4.3e-35) {
tmp = x_m - ((x_m * z) * y);
} else {
tmp = x_m * (1.0 - (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 <= 4.3d-35) then
tmp = x_m - ((x_m * z) * y)
else
tmp = x_m * (1.0d0 - (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 <= 4.3e-35) {
tmp = x_m - ((x_m * z) * y);
} else {
tmp = x_m * (1.0 - (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 <= 4.3e-35: tmp = x_m - ((x_m * z) * y) else: tmp = x_m * (1.0 - (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 (x_m <= 4.3e-35) tmp = Float64(x_m - Float64(Float64(x_m * z) * y)); else tmp = Float64(x_m * Float64(1.0 - Float64(z * y))); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (x_m <= 4.3e-35)
tmp = x_m - ((x_m * z) * y);
else
tmp = x_m * (1.0 - (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[x$95$m, 4.3e-35], N[(x$95$m - N[(N[(x$95$m * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 - N[(z * y), $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 4.3 \cdot 10^{-35}:\\
\;\;\;\;x\_m - \left(x\_m \cdot z\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - z \cdot y\right)\\
\end{array}
\end{array}
if x < 4.3000000000000002e-35Initial program 93.5%
Taylor expanded in z around inf 89.0%
Taylor expanded in z around 0 93.5%
associate-*r*96.7%
*-commutative96.7%
neg-mul-196.7%
sub-neg96.7%
associate-*r*89.6%
*-commutative89.6%
Simplified89.6%
if 4.3000000000000002e-35 < x Initial program 99.9%
Final simplification92.8%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z 7.5e+204) x_m (/ (* 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 <= 7.5e+204) {
tmp = x_m;
} else {
tmp = (x_m * z) / z;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 7.5d+204) then
tmp = x_m
else
tmp = (x_m * z) / z
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= 7.5e+204) {
tmp = x_m;
} else {
tmp = (x_m * z) / z;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if z <= 7.5e+204: tmp = x_m else: tmp = (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 <= 7.5e+204) tmp = x_m; else tmp = Float64(Float64(x_m * z) / z); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (z <= 7.5e+204)
tmp = x_m;
else
tmp = (x_m * z) / z;
end
tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[z, 7.5e+204], x$95$m, N[(N[(x$95$m * z), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 7.5 \cdot 10^{+204}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m \cdot z}{z}\\
\end{array}
\end{array}
if z < 7.4999999999999998e204Initial program 95.0%
Taylor expanded in y around 0 52.3%
if 7.4999999999999998e204 < z Initial program 99.9%
Taylor expanded in z around inf 95.5%
Taylor expanded in y around 0 5.0%
associate-*r/41.6%
Applied egg-rr41.6%
Final simplification51.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 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 95.5%
Taylor expanded in y around 0 48.2%
herbie shell --seed 2024111
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))