
(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 5e-31) (- x_m (* z (* x_m 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 <= 5e-31) {
tmp = x_m - (z * (x_m * 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 <= 5d-31) then
tmp = x_m - (z * (x_m * 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 <= 5e-31) {
tmp = x_m - (z * (x_m * 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 <= 5e-31: tmp = x_m - (z * (x_m * 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 <= 5e-31) tmp = Float64(x_m - Float64(z * Float64(x_m * 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 <= 5e-31)
tmp = x_m - (z * (x_m * 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, 5e-31], N[(x$95$m - N[(z * N[(x$95$m * y), $MachinePrecision]), $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 5 \cdot 10^{-31}:\\
\;\;\;\;x\_m - z \cdot \left(x\_m \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if x < 5e-31Initial program 95.7%
sub-neg95.7%
distribute-rgt-in95.7%
*-un-lft-identity95.7%
distribute-rgt-neg-in95.7%
Applied egg-rr95.7%
distribute-rgt-neg-out95.7%
distribute-lft-neg-out95.7%
associate-*r*93.7%
*-commutative93.7%
distribute-lft-neg-in93.7%
add-sqr-sqrt50.3%
sqrt-unprod61.9%
sqr-neg61.9%
sqrt-unprod34.9%
add-sqr-sqrt51.7%
*-commutative51.7%
distribute-lft-neg-in51.7%
cancel-sign-sub-inv51.7%
associate-*l*52.6%
*-commutative52.6%
associate-*r*49.5%
*-commutative49.5%
add-sqr-sqrt24.2%
sqrt-unprod60.7%
sqr-neg60.7%
sqrt-unprod46.0%
add-sqr-sqrt90.9%
*-commutative90.9%
Applied egg-rr90.9%
if 5e-31 < 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 simplification93.6%
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 -3.9e+46) (not (<= y 1.05e-101))) (* 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 <= -3.9e+46) || !(y <= 1.05e-101)) {
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 ((y <= (-3.9d+46)) .or. (.not. (y <= 1.05d-101))) 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 ((y <= -3.9e+46) || !(y <= 1.05e-101)) {
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 (y <= -3.9e+46) or not (y <= 1.05e-101): 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 ((y <= -3.9e+46) || !(y <= 1.05e-101)) 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 ((y <= -3.9e+46) || ~((y <= 1.05e-101)))
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[y, -3.9e+46], N[Not[LessEqual[y, 1.05e-101]], $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}\;y \leq -3.9 \cdot 10^{+46} \lor \neg \left(y \leq 1.05 \cdot 10^{-101}\right):\\
\;\;\;\;x\_m \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -3.89999999999999995e46 or 1.05000000000000008e-101 < y Initial program 94.3%
Taylor expanded in y around inf 60.5%
mul-1-neg60.5%
distribute-rgt-neg-in60.5%
distribute-rgt-neg-out60.5%
Simplified60.5%
if -3.89999999999999995e46 < y < 1.05000000000000008e-101Initial program 99.9%
Taylor expanded in y around 0 77.1%
Final simplification68.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 (or (<= y -1.1e+46) (not (<= y 1.05e-101))) (* z (* x_m (- 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 <= -1.1e+46) || !(y <= 1.05e-101)) {
tmp = z * (x_m * -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 ((y <= (-1.1d+46)) .or. (.not. (y <= 1.05d-101))) then
tmp = z * (x_m * -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 ((y <= -1.1e+46) || !(y <= 1.05e-101)) {
tmp = z * (x_m * -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 (y <= -1.1e+46) or not (y <= 1.05e-101): tmp = z * (x_m * -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 ((y <= -1.1e+46) || !(y <= 1.05e-101)) tmp = Float64(z * Float64(x_m * 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 ((y <= -1.1e+46) || ~((y <= 1.05e-101)))
tmp = z * (x_m * -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[y, -1.1e+46], N[Not[LessEqual[y, 1.05e-101]], $MachinePrecision]], N[(z * N[(x$95$m * (-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}\;y \leq -1.1 \cdot 10^{+46} \lor \neg \left(y \leq 1.05 \cdot 10^{-101}\right):\\
\;\;\;\;z \cdot \left(x\_m \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -1.1e46 or 1.05000000000000008e-101 < y Initial program 94.3%
sub-neg94.3%
distribute-rgt-in94.4%
*-un-lft-identity94.4%
distribute-rgt-neg-in94.4%
Applied egg-rr94.4%
distribute-rgt-neg-out94.4%
distribute-lft-neg-out94.4%
associate-*r*95.3%
*-commutative95.3%
distribute-lft-neg-in95.3%
add-sqr-sqrt48.6%
sqrt-unprod53.7%
sqr-neg53.7%
sqrt-unprod22.5%
add-sqr-sqrt34.2%
*-commutative34.2%
distribute-lft-neg-in34.2%
cancel-sign-sub-inv34.2%
associate-*l*34.1%
*-commutative34.1%
associate-*r*27.4%
*-commutative27.4%
add-sqr-sqrt11.5%
sqrt-unprod47.2%
sqr-neg47.2%
sqrt-unprod43.4%
add-sqr-sqrt89.2%
*-commutative89.2%
Applied egg-rr89.2%
Taylor expanded in z around inf 60.5%
mul-1-neg60.5%
*-commutative60.5%
*-commutative60.5%
associate-*r*62.7%
*-commutative62.7%
distribute-rgt-neg-out62.7%
*-commutative62.7%
Simplified62.7%
if -1.1e46 < y < 1.05000000000000008e-101Initial program 99.9%
Taylor expanded in y around 0 77.1%
Final simplification69.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 (<= y -6.2e+45)
(* x_m (* z (- y)))
(if (<= y 7.6e-102) 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 <= -6.2e+45) {
tmp = x_m * (z * -y);
} else if (y <= 7.6e-102) {
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 <= (-6.2d+45)) then
tmp = x_m * (z * -y)
else if (y <= 7.6d-102) 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 <= -6.2e+45) {
tmp = x_m * (z * -y);
} else if (y <= 7.6e-102) {
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 <= -6.2e+45: tmp = x_m * (z * -y) elif y <= 7.6e-102: 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 <= -6.2e+45) tmp = Float64(x_m * Float64(z * Float64(-y))); elseif (y <= 7.6e-102) 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 <= -6.2e+45)
tmp = x_m * (z * -y);
elseif (y <= 7.6e-102)
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, -6.2e+45], N[(x$95$m * N[(z * (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.6e-102], 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 -6.2 \cdot 10^{+45}:\\
\;\;\;\;x\_m \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{-102}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x\_m \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if y < -6.19999999999999975e45Initial program 91.6%
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 -6.19999999999999975e45 < y < 7.60000000000000052e-102Initial program 99.9%
Taylor expanded in y around 0 77.1%
if 7.60000000000000052e-102 < y Initial program 96.3%
Taylor expanded in y around inf 55.8%
mul-1-neg55.8%
associate-*r*55.7%
distribute-rgt-neg-in55.7%
*-commutative55.7%
associate-*r*56.9%
distribute-rgt-neg-out56.9%
Simplified56.9%
Final simplification68.6%
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 5e-31) (- x_m (* z (* x_m 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 <= 5e-31) {
tmp = x_m - (z * (x_m * 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 <= 5d-31) then
tmp = x_m - (z * (x_m * 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 <= 5e-31) {
tmp = x_m - (z * (x_m * 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 <= 5e-31: tmp = x_m - (z * (x_m * 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 <= 5e-31) tmp = Float64(x_m - Float64(z * Float64(x_m * 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 <= 5e-31)
tmp = x_m - (z * (x_m * 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, 5e-31], N[(x$95$m - N[(z * N[(x$95$m * y), $MachinePrecision]), $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 5 \cdot 10^{-31}:\\
\;\;\;\;x\_m - z \cdot \left(x\_m \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - z \cdot y\right)\\
\end{array}
\end{array}
if x < 5e-31Initial program 95.7%
sub-neg95.7%
distribute-rgt-in95.7%
*-un-lft-identity95.7%
distribute-rgt-neg-in95.7%
Applied egg-rr95.7%
distribute-rgt-neg-out95.7%
distribute-lft-neg-out95.7%
associate-*r*93.7%
*-commutative93.7%
distribute-lft-neg-in93.7%
add-sqr-sqrt50.3%
sqrt-unprod61.9%
sqr-neg61.9%
sqrt-unprod34.9%
add-sqr-sqrt51.7%
*-commutative51.7%
distribute-lft-neg-in51.7%
cancel-sign-sub-inv51.7%
associate-*l*52.6%
*-commutative52.6%
associate-*r*49.5%
*-commutative49.5%
add-sqr-sqrt24.2%
sqrt-unprod60.7%
sqr-neg60.7%
sqrt-unprod46.0%
add-sqr-sqrt90.9%
*-commutative90.9%
Applied egg-rr90.9%
if 5e-31 < x Initial program 99.9%
Final simplification93.6%
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 (- 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) {
return x_s * (x_m * (1.0 - (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 * (1.0d0 - (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 * (1.0 - (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 * (1.0 - (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(x_m * Float64(1.0 - Float64(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 * (1.0 - (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[(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 \left(x\_m \cdot \left(1 - z \cdot y\right)\right)
\end{array}
Initial program 97.0%
Final simplification97.0%
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.0%
Taylor expanded in y around 0 55.2%
Final simplification55.2%
herbie shell --seed 2024026
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))