
(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 1e-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 <= 1e-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 <= 1d-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 <= 1e-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 <= 1e-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 <= 1e-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 <= 1e-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, 1e-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 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 < 1e-26Initial program 95.0%
sub-neg95.0%
distribute-rgt-in95.0%
*-un-lft-identity95.0%
distribute-rgt-neg-in95.0%
Applied egg-rr95.0%
Taylor expanded in y around 0 95.0%
neg-mul-195.0%
associate-*r*94.0%
Simplified94.0%
if 1e-26 < 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%
distribute-rgt-neg-out99.9%
distribute-lft-neg-out99.9%
associate-*r*87.4%
*-commutative87.4%
distribute-lft-neg-in87.4%
add-sqr-sqrt46.5%
sqrt-unprod51.0%
sqr-neg51.0%
sqrt-unprod18.4%
add-sqr-sqrt40.6%
*-commutative40.6%
distribute-lft-neg-in40.6%
cancel-sign-sub-inv40.6%
associate-*l*46.8%
*-commutative46.8%
add-sqr-sqrt27.9%
sqrt-unprod72.1%
distribute-rgt-neg-out72.1%
distribute-rgt-neg-out72.1%
sqr-neg72.1%
sqrt-prod53.9%
Applied egg-rr99.9%
Final simplification95.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 (<= y -1.42e+69) (not (<= y 9.5e-77))) (* 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 <= -1.42e+69) || !(y <= 9.5e-77)) {
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 <= (-1.42d+69)) .or. (.not. (y <= 9.5d-77))) 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 <= -1.42e+69) || !(y <= 9.5e-77)) {
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 <= -1.42e+69) or not (y <= 9.5e-77): 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 <= -1.42e+69) || !(y <= 9.5e-77)) 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 <= -1.42e+69) || ~((y <= 9.5e-77)))
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, -1.42e+69], N[Not[LessEqual[y, 9.5e-77]], $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 -1.42 \cdot 10^{+69} \lor \neg \left(y \leq 9.5 \cdot 10^{-77}\right):\\
\;\;\;\;x\_m \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -1.42e69 or 9.5000000000000005e-77 < y Initial program 92.4%
Taylor expanded in y around inf 66.7%
mul-1-neg66.7%
distribute-rgt-neg-in66.7%
distribute-rgt-neg-out66.7%
Simplified66.7%
if -1.42e69 < y < 9.5000000000000005e-77Initial program 99.9%
Taylor expanded in y around 0 69.4%
Final simplification68.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 -1.68e+69)
(* x_m (* y (- z)))
(if (<= y 2.05e-72) 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 <= -1.68e+69) {
tmp = x_m * (y * -z);
} else if (y <= 2.05e-72) {
tmp = x_m;
} else {
tmp = y * (z * -x_m);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.68d+69)) then
tmp = x_m * (y * -z)
else if (y <= 2.05d-72) then
tmp = x_m
else
tmp = y * (z * -x_m)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -1.68e+69) {
tmp = x_m * (y * -z);
} else if (y <= 2.05e-72) {
tmp = x_m;
} else {
tmp = y * (z * -x_m);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if y <= -1.68e+69: tmp = x_m * (y * -z) elif y <= 2.05e-72: tmp = x_m else: tmp = y * (z * -x_m) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (y <= -1.68e+69) tmp = Float64(x_m * Float64(y * Float64(-z))); elseif (y <= 2.05e-72) tmp = x_m; else tmp = Float64(y * Float64(z * 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 <= -1.68e+69)
tmp = x_m * (y * -z);
elseif (y <= 2.05e-72)
tmp = x_m;
else
tmp = y * (z * -x_m);
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -1.68e+69], N[(x$95$m * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.05e-72], x$95$m, N[(y * N[(z * (-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 -1.68 \cdot 10^{+69}:\\
\;\;\;\;x\_m \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{-72}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\_m\right)\right)\\
\end{array}
\end{array}
if y < -1.68000000000000001e69Initial program 95.5%
Taylor expanded in y around inf 81.4%
mul-1-neg81.4%
distribute-rgt-neg-in81.4%
distribute-rgt-neg-out81.4%
Simplified81.4%
if -1.68000000000000001e69 < y < 2.05000000000000002e-72Initial program 99.9%
Taylor expanded in y around 0 69.4%
if 2.05000000000000002e-72 < y Initial program 90.8%
Taylor expanded in y around inf 59.1%
mul-1-neg59.1%
associate-*r*65.2%
distribute-rgt-neg-in65.2%
*-commutative65.2%
associate-*r*67.0%
distribute-rgt-neg-out67.0%
Simplified67.0%
Final simplification70.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 (<= y -1.25e+69)
(* x_m (* y (- z)))
(if (<= y 2.5e-71) 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 <= -1.25e+69) {
tmp = x_m * (y * -z);
} else if (y <= 2.5e-71) {
tmp = x_m;
} else {
tmp = (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 <= (-1.25d+69)) then
tmp = x_m * (y * -z)
else if (y <= 2.5d-71) then
tmp = x_m
else
tmp = (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 <= -1.25e+69) {
tmp = x_m * (y * -z);
} else if (y <= 2.5e-71) {
tmp = x_m;
} else {
tmp = (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 <= -1.25e+69: tmp = x_m * (y * -z) elif y <= 2.5e-71: tmp = x_m else: tmp = (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 (y <= -1.25e+69) tmp = Float64(x_m * Float64(y * Float64(-z))); elseif (y <= 2.5e-71) tmp = x_m; else tmp = Float64(Float64(x_m * y) * 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 <= -1.25e+69)
tmp = x_m * (y * -z);
elseif (y <= 2.5e-71)
tmp = x_m;
else
tmp = (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[y, -1.25e+69], N[(x$95$m * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e-71], x$95$m, N[(N[(x$95$m * y), $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}\;y \leq -1.25 \cdot 10^{+69}:\\
\;\;\;\;x\_m \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-71}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;\left(x\_m \cdot y\right) \cdot \left(-z\right)\\
\end{array}
\end{array}
if y < -1.25000000000000009e69Initial program 95.5%
Taylor expanded in y around inf 81.4%
mul-1-neg81.4%
distribute-rgt-neg-in81.4%
distribute-rgt-neg-out81.4%
Simplified81.4%
if -1.25000000000000009e69 < y < 2.49999999999999999e-71Initial program 99.9%
Taylor expanded in y around 0 69.4%
if 2.49999999999999999e-71 < y Initial program 90.8%
flip--65.6%
associate-*r/65.5%
metadata-eval65.5%
pow265.5%
+-commutative65.5%
fma-def65.5%
Applied egg-rr65.5%
associate-/l*65.6%
Simplified65.6%
Taylor expanded in y around inf 59.0%
div-inv59.1%
frac-2neg59.1%
metadata-eval59.1%
remove-double-div59.1%
distribute-rgt-neg-in59.1%
associate-*r*65.2%
distribute-lft-neg-in65.2%
distribute-rgt-neg-in65.2%
Applied egg-rr65.2%
Final simplification70.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) 4e+121) (* x_m (- 1.0 (* y z))) (* (* 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) <= 4e+121) {
tmp = x_m * (1.0 - (y * z));
} else {
tmp = (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) <= 4d+121) then
tmp = x_m * (1.0d0 - (y * z))
else
tmp = (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) <= 4e+121) {
tmp = x_m * (1.0 - (y * z));
} else {
tmp = (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) <= 4e+121: tmp = x_m * (1.0 - (y * z)) else: tmp = (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) <= 4e+121) tmp = Float64(x_m * Float64(1.0 - Float64(y * z))); else tmp = Float64(Float64(x_m * y) * 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 * z) <= 4e+121)
tmp = x_m * (1.0 - (y * z));
else
tmp = (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], 4e+121], N[(x$95$m * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m * y), $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}\;y \cdot z \leq 4 \cdot 10^{+121}:\\
\;\;\;\;x\_m \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x\_m \cdot y\right) \cdot \left(-z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < 4.00000000000000015e121Initial program 98.2%
if 4.00000000000000015e121 < (*.f64 y z) Initial program 83.7%
flip--35.8%
associate-*r/30.5%
metadata-eval30.5%
pow230.5%
+-commutative30.5%
fma-def30.5%
Applied egg-rr30.5%
associate-/l*35.9%
Simplified35.9%
Taylor expanded in y around inf 83.6%
div-inv83.6%
frac-2neg83.6%
metadata-eval83.6%
remove-double-div83.7%
distribute-rgt-neg-in83.7%
associate-*r*99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Applied egg-rr99.8%
Final simplification98.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) 4e+121) (- x_m (* x_m (* y z))) (* (* 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) <= 4e+121) {
tmp = x_m - (x_m * (y * z));
} else {
tmp = (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) <= 4d+121) then
tmp = x_m - (x_m * (y * z))
else
tmp = (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) <= 4e+121) {
tmp = x_m - (x_m * (y * z));
} else {
tmp = (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) <= 4e+121: tmp = x_m - (x_m * (y * z)) else: tmp = (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) <= 4e+121) tmp = Float64(x_m - Float64(x_m * Float64(y * z))); else tmp = Float64(Float64(x_m * y) * 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 * z) <= 4e+121)
tmp = x_m - (x_m * (y * z));
else
tmp = (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], 4e+121], N[(x$95$m - N[(x$95$m * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m * y), $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}\;y \cdot z \leq 4 \cdot 10^{+121}:\\
\;\;\;\;x\_m - x\_m \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x\_m \cdot y\right) \cdot \left(-z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < 4.00000000000000015e121Initial program 98.2%
sub-neg98.2%
distribute-rgt-in98.2%
*-un-lft-identity98.2%
distribute-rgt-neg-in98.2%
Applied egg-rr98.2%
distribute-rgt-neg-out98.2%
distribute-lft-neg-out98.2%
associate-*r*90.5%
*-commutative90.5%
distribute-lft-neg-in90.5%
add-sqr-sqrt51.0%
sqrt-unprod63.2%
sqr-neg63.2%
sqrt-unprod30.7%
add-sqr-sqrt52.0%
*-commutative52.0%
distribute-lft-neg-in52.0%
cancel-sign-sub-inv52.0%
associate-*l*55.2%
*-commutative55.2%
add-sqr-sqrt33.5%
sqrt-unprod66.9%
distribute-rgt-neg-out66.9%
distribute-rgt-neg-out66.9%
sqr-neg66.9%
sqrt-prod46.5%
Applied egg-rr98.2%
if 4.00000000000000015e121 < (*.f64 y z) Initial program 83.7%
flip--35.8%
associate-*r/30.5%
metadata-eval30.5%
pow230.5%
+-commutative30.5%
fma-def30.5%
Applied egg-rr30.5%
associate-/l*35.9%
Simplified35.9%
Taylor expanded in y around inf 83.6%
div-inv83.6%
frac-2neg83.6%
metadata-eval83.6%
remove-double-div83.7%
distribute-rgt-neg-in83.7%
associate-*r*99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Applied egg-rr99.8%
Final simplification98.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 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.2%
Taylor expanded in y around 0 49.1%
Final simplification49.1%
herbie shell --seed 2024040
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))