
(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 3.2e-71) (- 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 <= 3.2e-71) {
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 <= 3.2d-71) 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 <= 3.2e-71) {
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 <= 3.2e-71: 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 <= 3.2e-71) 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 <= 3.2e-71)
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, 3.2e-71], 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 3.2 \cdot 10^{-71}:\\
\;\;\;\;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 < 3.1999999999999999e-71Initial program 93.1%
Taylor expanded in y around 0 93.1%
mul-1-neg93.1%
associate-*r*93.6%
Simplified93.6%
if 3.1999999999999999e-71 < 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 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
(let* ((t_0 (* x_m (- 1.0 (* y z)))))
(*
x_s
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 INFINITY)))
(* (* x_m y) (- z))
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 = x_m * (1.0 - (y * z));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= ((double) INFINITY))) {
tmp = (x_m * y) * -z;
} else {
tmp = t_0;
}
return x_s * tmp;
}
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 <= -Double.POSITIVE_INFINITY) || !(t_0 <= Double.POSITIVE_INFINITY)) {
tmp = (x_m * y) * -z;
} 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 = x_m * (1.0 - (y * z)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= math.inf): tmp = (x_m * y) * -z 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(x_m * Float64(1.0 - Float64(y * z))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= Inf)) tmp = Float64(Float64(x_m * y) * Float64(-z)); 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 = x_m * (1.0 - (y * z));
tmp = 0.0;
if ((t_0 <= -Inf) || ~((t_0 <= Inf)))
tmp = (x_m * y) * -z;
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[(x$95$m * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], N[(N[(x$95$m * y), $MachinePrecision] * (-z)), $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 := x\_m \cdot \left(1 - y \cdot z\right)\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;\left(x\_m \cdot y\right) \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 y z))) < -inf.0 or +inf.0 < (*.f64 x (-.f64 1 (*.f64 y z))) Initial program 77.3%
Taylor expanded in y around inf 77.3%
mul-1-neg77.3%
associate-*r*100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
Simplified100.0%
if -inf.0 < (*.f64 x (-.f64 1 (*.f64 y z))) < +inf.0Initial program 97.4%
Final simplification97.7%
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+154) (not (<= t_0 INFINITY)))
(- x_m (* y (* x_m z)))
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 = x_m * (1.0 - (y * z));
double tmp;
if ((t_0 <= -4e+154) || !(t_0 <= ((double) INFINITY))) {
tmp = x_m - (y * (x_m * z));
} else {
tmp = t_0;
}
return x_s * tmp;
}
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+154) || !(t_0 <= Double.POSITIVE_INFINITY)) {
tmp = x_m - (y * (x_m * z));
} 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 = x_m * (1.0 - (y * z)) tmp = 0 if (t_0 <= -4e+154) or not (t_0 <= math.inf): tmp = x_m - (y * (x_m * z)) 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(x_m * Float64(1.0 - Float64(y * z))) tmp = 0.0 if ((t_0 <= -4e+154) || !(t_0 <= Inf)) tmp = Float64(x_m - Float64(y * Float64(x_m * z))); 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 = x_m * (1.0 - (y * z));
tmp = 0.0;
if ((t_0 <= -4e+154) || ~((t_0 <= Inf)))
tmp = x_m - (y * (x_m * z));
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[(x$95$m * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[Or[LessEqual[t$95$0, -4e+154], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], N[(x$95$m - N[(y * N[(x$95$m * z), $MachinePrecision]), $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 := x\_m \cdot \left(1 - y \cdot z\right)\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+154} \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;x\_m - y \cdot \left(x\_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 y z))) < -4.00000000000000015e154 or +inf.0 < (*.f64 x (-.f64 1 (*.f64 y z))) Initial program 88.9%
sub-neg88.9%
distribute-rgt-in88.9%
*-un-lft-identity88.9%
distribute-rgt-neg-in88.9%
Applied egg-rr88.9%
*-commutative88.9%
associate-*r*87.4%
distribute-rgt-neg-in87.4%
distribute-lft-neg-in87.4%
add-sqr-sqrt40.1%
sqrt-unprod35.7%
sqr-neg35.7%
sqrt-unprod3.5%
add-sqr-sqrt17.0%
cancel-sign-sub-inv17.0%
associate-*r*23.5%
*-commutative23.5%
associate-*l*18.5%
add-sqr-sqrt6.8%
sqrt-unprod39.7%
sqr-neg39.7%
sqrt-unprod38.8%
add-sqr-sqrt93.8%
Applied egg-rr93.8%
if -4.00000000000000015e154 < (*.f64 x (-.f64 1 (*.f64 y z))) < +inf.0Initial program 97.0%
Final simplification96.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 -6.2e+101) (not (<= y 6.8e-74))) (* 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 <= -6.2e+101) || !(y <= 6.8e-74)) {
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 <= (-6.2d+101)) .or. (.not. (y <= 6.8d-74))) 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 <= -6.2e+101) || !(y <= 6.8e-74)) {
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 <= -6.2e+101) or not (y <= 6.8e-74): 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 <= -6.2e+101) || !(y <= 6.8e-74)) 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 <= -6.2e+101) || ~((y <= 6.8e-74)))
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, -6.2e+101], N[Not[LessEqual[y, 6.8e-74]], $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 -6.2 \cdot 10^{+101} \lor \neg \left(y \leq 6.8 \cdot 10^{-74}\right):\\
\;\;\;\;x\_m \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -6.19999999999999998e101 or 6.8000000000000001e-74 < y Initial program 91.4%
Taylor expanded in y around inf 66.5%
mul-1-neg66.5%
associate-*r*71.4%
*-commutative71.4%
distribute-lft-neg-in71.4%
Simplified71.4%
Taylor expanded in z around 0 66.5%
mul-1-neg66.5%
*-commutative66.5%
distribute-rgt-neg-in66.5%
*-commutative66.5%
distribute-rgt-neg-in66.5%
Simplified66.5%
if -6.19999999999999998e101 < y < 6.8000000000000001e-74Initial program 99.1%
Taylor expanded in y around 0 73.5%
Final simplification69.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 -4.3e+52) (not (<= y 6e-74))) (* (* 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 <= -4.3e+52) || !(y <= 6e-74)) {
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 <= (-4.3d+52)) .or. (.not. (y <= 6d-74))) 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 <= -4.3e+52) || !(y <= 6e-74)) {
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 <= -4.3e+52) or not (y <= 6e-74): 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 <= -4.3e+52) || !(y <= 6e-74)) tmp = Float64(Float64(x_m * 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 <= -4.3e+52) || ~((y <= 6e-74)))
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, -4.3e+52], N[Not[LessEqual[y, 6e-74]], $MachinePrecision]], N[(N[(x$95$m * y), $MachinePrecision] * (-z)), $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 -4.3 \cdot 10^{+52} \lor \neg \left(y \leq 6 \cdot 10^{-74}\right):\\
\;\;\;\;\left(x\_m \cdot y\right) \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -4.3e52 or 6.00000000000000014e-74 < y Initial program 91.6%
Taylor expanded in y around inf 63.4%
mul-1-neg63.4%
associate-*r*68.4%
*-commutative68.4%
distribute-lft-neg-in68.4%
Simplified68.4%
if -4.3e52 < y < 6.00000000000000014e-74Initial program 99.9%
Taylor expanded in y around 0 76.5%
Final simplification71.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 (<= x_m 1e-55) (- x_m (* (* x_m y) 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 (x_m <= 1e-55) {
tmp = x_m - ((x_m * y) * 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 (x_m <= 1d-55) then
tmp = x_m - ((x_m * y) * 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 (x_m <= 1e-55) {
tmp = x_m - ((x_m * y) * 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 x_m <= 1e-55: tmp = x_m - ((x_m * y) * 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 (x_m <= 1e-55) tmp = Float64(x_m - Float64(Float64(x_m * y) * 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 (x_m <= 1e-55)
tmp = x_m - ((x_m * y) * 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[LessEqual[x$95$m, 1e-55], N[(x$95$m - N[(N[(x$95$m * y), $MachinePrecision] * 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}\;x\_m \leq 10^{-55}:\\
\;\;\;\;x\_m - \left(x\_m \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if x < 9.99999999999999995e-56Initial program 93.3%
Taylor expanded in y around 0 93.3%
mul-1-neg93.3%
associate-*r*93.7%
Simplified93.7%
if 9.99999999999999995e-56 < x Initial program 99.8%
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 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.1%
Taylor expanded in y around 0 49.4%
Final simplification49.4%
herbie shell --seed 2024046
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))