
(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 5e-107) (- 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-107) {
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-107) 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-107) {
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-107: 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-107) 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-107)
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-107], 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^{-107}:\\
\;\;\;\;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 < 4.99999999999999971e-107Initial program 93.1%
sub-neg93.1%
distribute-rgt-in93.1%
*-un-lft-identity93.1%
distribute-rgt-neg-in93.1%
Applied egg-rr93.1%
distribute-rgt-neg-out93.1%
distribute-lft-neg-out93.1%
associate-*r*91.5%
*-commutative91.5%
distribute-lft-neg-in91.5%
add-sqr-sqrt47.9%
sqrt-unprod57.4%
sqr-neg57.4%
sqrt-unprod31.9%
add-sqr-sqrt50.0%
*-commutative50.0%
distribute-lft-neg-in50.0%
cancel-sign-sub-inv50.0%
associate-*l*51.9%
*-commutative51.9%
associate-*l*51.0%
add-sqr-sqrt26.9%
sqrt-unprod67.5%
sqr-neg67.5%
sqrt-unprod51.2%
add-sqr-sqrt95.9%
Applied egg-rr95.9%
if 4.99999999999999971e-107 < x Initial program 99.9%
Final simplification97.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
(let* ((t_0 (* y (- (* x_m z)))))
(*
x_s
(if (<= (* z y) -100000.0)
t_0
(if (<= (* z y) 0.0004)
x_m
(if (<= (* z y) 1e+258) (* x_m (* z (- y))) t_0))))))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 t_0 = y * -(x_m * z);
double tmp;
if ((z * y) <= -100000.0) {
tmp = t_0;
} else if ((z * y) <= 0.0004) {
tmp = x_m;
} else if ((z * y) <= 1e+258) {
tmp = x_m * (z * -y);
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = y * -(x_m * z)
if ((z * y) <= (-100000.0d0)) then
tmp = t_0
else if ((z * y) <= 0.0004d0) then
tmp = x_m
else if ((z * y) <= 1d+258) then
tmp = x_m * (z * -y)
else
tmp = t_0
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 t_0 = y * -(x_m * z);
double tmp;
if ((z * y) <= -100000.0) {
tmp = t_0;
} else if ((z * y) <= 0.0004) {
tmp = x_m;
} else if ((z * y) <= 1e+258) {
tmp = x_m * (z * -y);
} else {
tmp = t_0;
}
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): t_0 = y * -(x_m * z) tmp = 0 if (z * y) <= -100000.0: tmp = t_0 elif (z * y) <= 0.0004: tmp = x_m elif (z * y) <= 1e+258: tmp = x_m * (z * -y) else: tmp = t_0 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) t_0 = Float64(y * Float64(-Float64(x_m * z))) tmp = 0.0 if (Float64(z * y) <= -100000.0) tmp = t_0; elseif (Float64(z * y) <= 0.0004) tmp = x_m; elseif (Float64(z * y) <= 1e+258) tmp = Float64(x_m * Float64(z * Float64(-y))); else tmp = t_0; 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)
t_0 = y * -(x_m * z);
tmp = 0.0;
if ((z * y) <= -100000.0)
tmp = t_0;
elseif ((z * y) <= 0.0004)
tmp = x_m;
elseif ((z * y) <= 1e+258)
tmp = x_m * (z * -y);
else
tmp = t_0;
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_] := Block[{t$95$0 = N[(y * (-N[(x$95$m * z), $MachinePrecision])), $MachinePrecision]}, N[(x$95$s * If[LessEqual[N[(z * y), $MachinePrecision], -100000.0], t$95$0, If[LessEqual[N[(z * y), $MachinePrecision], 0.0004], x$95$m, If[LessEqual[N[(z * y), $MachinePrecision], 1e+258], N[(x$95$m * N[(z * (-y)), $MachinePrecision]), $MachinePrecision], t$95$0]]]), $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])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(-x_m \cdot z\right)\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot y \leq -100000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \cdot y \leq 0.0004:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \cdot y \leq 10^{+258}:\\
\;\;\;\;x_m \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 y z) < -1e5 or 1.00000000000000006e258 < (*.f64 y z) Initial program 85.2%
Taylor expanded in y around inf 83.9%
mul-1-neg83.9%
associate-*r*94.8%
distribute-rgt-neg-in94.8%
*-commutative94.8%
associate-*r*91.9%
distribute-rgt-neg-out91.9%
Simplified91.9%
if -1e5 < (*.f64 y z) < 4.00000000000000019e-4Initial program 100.0%
Taylor expanded in y around 0 97.7%
if 4.00000000000000019e-4 < (*.f64 y z) < 1.00000000000000006e258Initial program 99.8%
Taylor expanded in y around inf 95.3%
mul-1-neg95.3%
distribute-rgt-neg-in95.3%
distribute-rgt-neg-out95.3%
Simplified95.3%
Final simplification95.5%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= (* z y) -400.0) (not (<= (* z y) 0.0004)))
(* 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 * y) <= -400.0) || !((z * y) <= 0.0004)) {
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 * y) <= (-400.0d0)) .or. (.not. ((z * y) <= 0.0004d0))) 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 * y) <= -400.0) || !((z * y) <= 0.0004)) {
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 * y) <= -400.0) or not ((z * y) <= 0.0004): 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 ((Float64(z * y) <= -400.0) || !(Float64(z * y) <= 0.0004)) 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 * y) <= -400.0) || ~(((z * y) <= 0.0004)))
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[N[(z * y), $MachinePrecision], -400.0], N[Not[LessEqual[N[(z * y), $MachinePrecision], 0.0004]], $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 \cdot y \leq -400 \lor \neg \left(z \cdot y \leq 0.0004\right):\\
\;\;\;\;x_m \cdot \left(z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if (*.f64 y z) < -400 or 4.00000000000000019e-4 < (*.f64 y z) Initial program 90.6%
Taylor expanded in y around inf 87.6%
mul-1-neg87.6%
distribute-rgt-neg-in87.6%
distribute-rgt-neg-out87.6%
Simplified87.6%
if -400 < (*.f64 y z) < 4.00000000000000019e-4Initial program 100.0%
Taylor expanded in y around 0 98.3%
Final simplification93.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 (<= (* z y) -100000.0)
(* y (- (* x_m z)))
(if (<= (* z y) 0.0004) x_m (* z (* x_m (- 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) <= -100000.0) {
tmp = y * -(x_m * z);
} else if ((z * y) <= 0.0004) {
tmp = x_m;
} else {
tmp = z * (x_m * -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) <= (-100000.0d0)) then
tmp = y * -(x_m * z)
else if ((z * y) <= 0.0004d0) then
tmp = x_m
else
tmp = z * (x_m * -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) <= -100000.0) {
tmp = y * -(x_m * z);
} else if ((z * y) <= 0.0004) {
tmp = x_m;
} else {
tmp = z * (x_m * -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) <= -100000.0: tmp = y * -(x_m * z) elif (z * y) <= 0.0004: tmp = x_m else: tmp = z * (x_m * -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) <= -100000.0) tmp = Float64(y * Float64(-Float64(x_m * z))); elseif (Float64(z * y) <= 0.0004) tmp = x_m; else tmp = Float64(z * Float64(x_m * 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 * y) <= -100000.0)
tmp = y * -(x_m * z);
elseif ((z * y) <= 0.0004)
tmp = x_m;
else
tmp = z * (x_m * -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], -100000.0], N[(y * (-N[(x$95$m * z), $MachinePrecision])), $MachinePrecision], If[LessEqual[N[(z * y), $MachinePrecision], 0.0004], x$95$m, N[(z * N[(x$95$m * (-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 \cdot y \leq -100000:\\
\;\;\;\;y \cdot \left(-x_m \cdot z\right)\\
\mathbf{elif}\;z \cdot y \leq 0.0004:\\
\;\;\;\;x_m\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x_m \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -1e5Initial program 93.7%
Taylor expanded in y around inf 92.1%
mul-1-neg92.1%
associate-*r*93.5%
distribute-rgt-neg-in93.5%
*-commutative93.5%
associate-*r*89.9%
distribute-rgt-neg-out89.9%
Simplified89.9%
if -1e5 < (*.f64 y z) < 4.00000000000000019e-4Initial program 100.0%
Taylor expanded in y around 0 97.7%
if 4.00000000000000019e-4 < (*.f64 y z) Initial program 87.2%
flip--52.8%
associate-*r/52.7%
metadata-eval52.7%
pow252.7%
+-commutative52.7%
fma-def52.7%
Applied egg-rr52.7%
associate-*l/47.5%
Simplified47.5%
Taylor expanded in y around inf 44.2%
Taylor expanded in y around inf 83.9%
mul-1-neg83.9%
associate-*r*93.3%
distribute-rgt-neg-in93.3%
Simplified93.3%
Final simplification94.8%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= (* z y) 1e+258) (* x_m (- 1.0 (* z y))) (* 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 ((z * y) <= 1e+258) {
tmp = x_m * (1.0 - (z * y));
} 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 ((z * y) <= 1d+258) then
tmp = x_m * (1.0d0 - (z * y))
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 ((z * y) <= 1e+258) {
tmp = x_m * (1.0 - (z * y));
} 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 (z * y) <= 1e+258: tmp = x_m * (1.0 - (z * y)) 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 (Float64(z * y) <= 1e+258) tmp = Float64(x_m * Float64(1.0 - Float64(z * y))); else tmp = Float64(y * Float64(-Float64(x_m * 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 * y) <= 1e+258)
tmp = x_m * (1.0 - (z * y));
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[N[(z * y), $MachinePrecision], 1e+258], N[(x$95$m * N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}\;z \cdot y \leq 10^{+258}:\\
\;\;\;\;x_m \cdot \left(1 - z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-x_m \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < 1.00000000000000006e258Initial program 98.3%
if 1.00000000000000006e258 < (*.f64 y z) Initial program 52.7%
Taylor expanded in y around inf 52.7%
mul-1-neg52.7%
associate-*r*99.6%
distribute-rgt-neg-in99.6%
*-commutative99.6%
associate-*r*99.7%
distribute-rgt-neg-out99.7%
Simplified99.7%
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 95.5%
Taylor expanded in y around 0 53.3%
Final simplification53.3%
herbie shell --seed 2024018
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))