
(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
(let* ((t_0 (* x_m (- 1.0 (* y z)))))
(*
x_s
(if (or (<= t_0 -4e+211) (not (<= t_0 1e+293)))
(- x_m (* z (* x_m y)))
(- 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 t_0 = x_m * (1.0 - (y * z));
double tmp;
if ((t_0 <= -4e+211) || !(t_0 <= 1e+293)) {
tmp = x_m - (z * (x_m * y));
} 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) :: t_0
real(8) :: tmp
t_0 = x_m * (1.0d0 - (y * z))
if ((t_0 <= (-4d+211)) .or. (.not. (t_0 <= 1d+293))) then
tmp = x_m - (z * (x_m * y))
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 t_0 = x_m * (1.0 - (y * z));
double tmp;
if ((t_0 <= -4e+211) || !(t_0 <= 1e+293)) {
tmp = x_m - (z * (x_m * y));
} 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): t_0 = x_m * (1.0 - (y * z)) tmp = 0 if (t_0 <= -4e+211) or not (t_0 <= 1e+293): tmp = x_m - (z * (x_m * y)) 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) t_0 = Float64(x_m * Float64(1.0 - Float64(y * z))) tmp = 0.0 if ((t_0 <= -4e+211) || !(t_0 <= 1e+293)) tmp = Float64(x_m - Float64(z * Float64(x_m * y))); 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)
t_0 = x_m * (1.0 - (y * z));
tmp = 0.0;
if ((t_0 <= -4e+211) || ~((t_0 <= 1e+293)))
tmp = x_m - (z * (x_m * y));
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_] := Block[{t$95$0 = N[(x$95$m * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[Or[LessEqual[t$95$0, -4e+211], N[Not[LessEqual[t$95$0, 1e+293]], $MachinePrecision]], N[(x$95$m - N[(z * N[(x$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
\begin{array}{l}
t_0 := x\_m \cdot \left(1 - y \cdot z\right)\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+211} \lor \neg \left(t\_0 \leq 10^{+293}\right):\\
\;\;\;\;x\_m - z \cdot \left(x\_m \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 y z))) < -3.9999999999999998e211 or 9.9999999999999992e292 < (*.f64 x (-.f64 1 (*.f64 y z))) Initial program 87.0%
Taylor expanded in y around 0 87.0%
mul-1-neg87.0%
Simplified87.0%
unsub-neg87.0%
*-commutative87.0%
associate-*l*88.4%
Applied egg-rr88.4%
rem-cube-cbrt88.1%
Applied egg-rr88.1%
rem-cube-cbrt88.4%
*-commutative88.4%
associate-*r*98.5%
Applied egg-rr98.5%
if -3.9999999999999998e211 < (*.f64 x (-.f64 1 (*.f64 y z))) < 9.9999999999999992e292Initial program 99.8%
Taylor expanded in y around 0 99.8%
mul-1-neg99.8%
Simplified99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*93.8%
Applied egg-rr93.8%
Taylor expanded in y around 0 99.8%
Final simplification99.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 (<= x_m 8e-28)
(- x_m (* (sqrt x_m) (* y (* z (sqrt x_m)))))
(- 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 <= 8e-28) {
tmp = x_m - (sqrt(x_m) * (y * (z * sqrt(x_m))));
} 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 <= 8d-28) then
tmp = x_m - (sqrt(x_m) * (y * (z * sqrt(x_m))))
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 <= 8e-28) {
tmp = x_m - (Math.sqrt(x_m) * (y * (z * Math.sqrt(x_m))));
} 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 <= 8e-28: tmp = x_m - (math.sqrt(x_m) * (y * (z * math.sqrt(x_m)))) 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 <= 8e-28) tmp = Float64(x_m - Float64(sqrt(x_m) * Float64(y * Float64(z * sqrt(x_m))))); 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 <= 8e-28)
tmp = x_m - (sqrt(x_m) * (y * (z * sqrt(x_m))));
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, 8e-28], N[(x$95$m - N[(N[Sqrt[x$95$m], $MachinePrecision] * N[(y * N[(z * N[Sqrt[x$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 8 \cdot 10^{-28}:\\
\;\;\;\;x\_m - \sqrt{x\_m} \cdot \left(y \cdot \left(z \cdot \sqrt{x\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if x < 7.99999999999999977e-28Initial program 94.5%
Taylor expanded in y around 0 94.5%
mul-1-neg94.5%
Simplified94.5%
add-cube-cbrt94.0%
pow394.0%
*-commutative94.0%
associate-*l*93.2%
Applied egg-rr93.2%
rem-cube-cbrt93.7%
associate-*r*94.5%
add-sqr-sqrt27.2%
associate-*r*27.2%
Applied egg-rr27.2%
Taylor expanded in y around 0 27.2%
*-commutative27.2%
associate-*r*29.6%
Simplified29.6%
if 7.99999999999999977e-28 < x Initial program 99.8%
Taylor expanded in y around 0 99.9%
mul-1-neg99.9%
Simplified99.9%
unsub-neg99.9%
*-commutative99.9%
associate-*l*89.2%
Applied egg-rr89.2%
Taylor expanded in y around 0 99.9%
Final simplification51.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 (* x_m (* y (- z)))) (t_1 (* y (* x_m (- z)))))
(*
x_s
(if (<= (* y z) -1e+164)
t_1
(if (<= (* y z) -1000000.0)
t_0
(if (<= (* y z) 0.2) x_m (if (<= (* y z) 1e+286) t_0 t_1)))))))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 = x_m * (y * -z);
double t_1 = y * (x_m * -z);
double tmp;
if ((y * z) <= -1e+164) {
tmp = t_1;
} else if ((y * z) <= -1000000.0) {
tmp = t_0;
} else if ((y * z) <= 0.2) {
tmp = x_m;
} else if ((y * z) <= 1e+286) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = x_m * (y * -z)
t_1 = y * (x_m * -z)
if ((y * z) <= (-1d+164)) then
tmp = t_1
else if ((y * z) <= (-1000000.0d0)) then
tmp = t_0
else if ((y * z) <= 0.2d0) then
tmp = x_m
else if ((y * z) <= 1d+286) then
tmp = t_0
else
tmp = t_1
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 = x_m * (y * -z);
double t_1 = y * (x_m * -z);
double tmp;
if ((y * z) <= -1e+164) {
tmp = t_1;
} else if ((y * z) <= -1000000.0) {
tmp = t_0;
} else if ((y * z) <= 0.2) {
tmp = x_m;
} else if ((y * z) <= 1e+286) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = x_m * (y * -z) t_1 = y * (x_m * -z) tmp = 0 if (y * z) <= -1e+164: tmp = t_1 elif (y * z) <= -1000000.0: tmp = t_0 elif (y * z) <= 0.2: tmp = x_m elif (y * z) <= 1e+286: tmp = t_0 else: tmp = t_1 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(x_m * Float64(y * Float64(-z))) t_1 = Float64(y * Float64(x_m * Float64(-z))) tmp = 0.0 if (Float64(y * z) <= -1e+164) tmp = t_1; elseif (Float64(y * z) <= -1000000.0) tmp = t_0; elseif (Float64(y * z) <= 0.2) tmp = x_m; elseif (Float64(y * z) <= 1e+286) tmp = t_0; else tmp = t_1; 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 = x_m * (y * -z);
t_1 = y * (x_m * -z);
tmp = 0.0;
if ((y * z) <= -1e+164)
tmp = t_1;
elseif ((y * z) <= -1000000.0)
tmp = t_0;
elseif ((y * z) <= 0.2)
tmp = x_m;
elseif ((y * z) <= 1e+286)
tmp = t_0;
else
tmp = t_1;
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[(x$95$m * N[(y * (-z)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[N[(y * z), $MachinePrecision], -1e+164], t$95$1, If[LessEqual[N[(y * z), $MachinePrecision], -1000000.0], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 0.2], x$95$m, If[LessEqual[N[(y * z), $MachinePrecision], 1e+286], t$95$0, t$95$1]]]]), $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 := x\_m \cdot \left(y \cdot \left(-z\right)\right)\\
t_1 := y \cdot \left(x\_m \cdot \left(-z\right)\right)\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+164}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \cdot z \leq -1000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 0.2:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \cdot z \leq 10^{+286}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if (*.f64 y z) < -1e164 or 1.00000000000000003e286 < (*.f64 y z) Initial program 78.9%
Taylor expanded in y around 0 78.9%
mul-1-neg78.9%
Simplified78.9%
Taylor expanded in y around inf 78.9%
mul-1-neg78.9%
*-commutative78.9%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
if -1e164 < (*.f64 y z) < -1e6 or 0.20000000000000001 < (*.f64 y z) < 1.00000000000000003e286Initial program 99.6%
Taylor expanded in y around inf 95.1%
mul-1-neg95.1%
distribute-rgt-neg-in95.1%
distribute-rgt-neg-in95.1%
Simplified95.1%
if -1e6 < (*.f64 y z) < 0.20000000000000001Initial program 99.9%
Taylor expanded in y around 0 96.8%
Final simplification96.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 (or (<= (* y z) -1e+164) (not (<= (* y z) 1e+286)))
(* y (* x_m (- z)))
(* x_m (- 1.0 (* y z))))))x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (((y * z) <= -1e+164) || !((y * z) <= 1e+286)) {
tmp = y * (x_m * -z);
} else {
tmp = x_m * (1.0 - (y * z));
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (((y * z) <= (-1d+164)) .or. (.not. ((y * z) <= 1d+286))) then
tmp = y * (x_m * -z)
else
tmp = x_m * (1.0d0 - (y * z))
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (((y * z) <= -1e+164) || !((y * z) <= 1e+286)) {
tmp = y * (x_m * -z);
} else {
tmp = x_m * (1.0 - (y * z));
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if ((y * z) <= -1e+164) or not ((y * z) <= 1e+286): tmp = y * (x_m * -z) else: tmp = x_m * (1.0 - (y * z)) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if ((Float64(y * z) <= -1e+164) || !(Float64(y * z) <= 1e+286)) tmp = Float64(y * Float64(x_m * Float64(-z))); else tmp = Float64(x_m * Float64(1.0 - Float64(y * z))); end return Float64(x_s * tmp) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (((y * z) <= -1e+164) || ~(((y * z) <= 1e+286)))
tmp = y * (x_m * -z);
else
tmp = x_m * (1.0 - (y * z));
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[N[(y * z), $MachinePrecision], -1e+164], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1e+286]], $MachinePrecision]], N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+164} \lor \neg \left(y \cdot z \leq 10^{+286}\right):\\
\;\;\;\;y \cdot \left(x\_m \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -1e164 or 1.00000000000000003e286 < (*.f64 y z) Initial program 78.9%
Taylor expanded in y around 0 78.9%
mul-1-neg78.9%
Simplified78.9%
Taylor expanded in y around inf 78.9%
mul-1-neg78.9%
*-commutative78.9%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
if -1e164 < (*.f64 y z) < 1.00000000000000003e286Initial program 99.8%
Final simplification99.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 (or (<= (* y z) -1e+164) (not (<= (* y z) 1e+286)))
(* y (* x_m (- z)))
(- x_m (* x_m (* y z))))))x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (((y * z) <= -1e+164) || !((y * z) <= 1e+286)) {
tmp = y * (x_m * -z);
} else {
tmp = x_m - (x_m * (y * z));
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (((y * z) <= (-1d+164)) .or. (.not. ((y * z) <= 1d+286))) then
tmp = y * (x_m * -z)
else
tmp = x_m - (x_m * (y * z))
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (((y * z) <= -1e+164) || !((y * z) <= 1e+286)) {
tmp = y * (x_m * -z);
} else {
tmp = x_m - (x_m * (y * z));
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if ((y * z) <= -1e+164) or not ((y * z) <= 1e+286): tmp = y * (x_m * -z) else: tmp = x_m - (x_m * (y * z)) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if ((Float64(y * z) <= -1e+164) || !(Float64(y * z) <= 1e+286)) tmp = Float64(y * Float64(x_m * Float64(-z))); else tmp = Float64(x_m - Float64(x_m * Float64(y * z))); end return Float64(x_s * tmp) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (((y * z) <= -1e+164) || ~(((y * z) <= 1e+286)))
tmp = y * (x_m * -z);
else
tmp = x_m - (x_m * (y * z));
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[N[(y * z), $MachinePrecision], -1e+164], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1e+286]], $MachinePrecision]], N[(y * N[(x$95$m * (-z)), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+164} \lor \neg \left(y \cdot z \leq 10^{+286}\right):\\
\;\;\;\;y \cdot \left(x\_m \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -1e164 or 1.00000000000000003e286 < (*.f64 y z) Initial program 78.9%
Taylor expanded in y around 0 78.9%
mul-1-neg78.9%
Simplified78.9%
Taylor expanded in y around inf 78.9%
mul-1-neg78.9%
*-commutative78.9%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
if -1e164 < (*.f64 y z) < 1.00000000000000003e286Initial program 99.8%
Taylor expanded in y around 0 99.8%
mul-1-neg99.8%
Simplified99.8%
unsub-neg99.8%
*-commutative99.8%
associate-*l*90.7%
Applied egg-rr90.7%
Taylor expanded in y around 0 99.8%
Final simplification99.9%
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 z) -1000000.0) (not (<= (* y z) 0.2)))
(* 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 * z) <= -1000000.0) || !((y * z) <= 0.2)) {
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 * z) <= (-1000000.0d0)) .or. (.not. ((y * z) <= 0.2d0))) 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 * z) <= -1000000.0) || !((y * z) <= 0.2)) {
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 * z) <= -1000000.0) or not ((y * z) <= 0.2): 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 ((Float64(y * z) <= -1000000.0) || !(Float64(y * z) <= 0.2)) 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 * z) <= -1000000.0) || ~(((y * z) <= 0.2)))
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[N[(y * z), $MachinePrecision], -1000000.0], N[Not[LessEqual[N[(y * z), $MachinePrecision], 0.2]], $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 \cdot z \leq -1000000 \lor \neg \left(y \cdot z \leq 0.2\right):\\
\;\;\;\;x\_m \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if (*.f64 y z) < -1e6 or 0.20000000000000001 < (*.f64 y z) Initial program 91.9%
Taylor expanded in y around inf 89.1%
mul-1-neg89.1%
distribute-rgt-neg-in89.1%
distribute-rgt-neg-in89.1%
Simplified89.1%
if -1e6 < (*.f64 y z) < 0.20000000000000001Initial program 99.9%
Taylor expanded in y around 0 96.8%
Final simplification93.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 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 52.8%
Final simplification52.8%
herbie shell --seed 2024027
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))